CSES - HIIT Open 2016 - Results
Submission details
Task:Interesting number
Sender:Ace of Spades
Submission time:2016-05-28 11:24:14 +0300
Language:C++
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.06 sdetails
#2ACCEPTED0.05 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:39:43: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for(int j = 0; j < v.size(); ++j) {
                                           ^

Code

#include<bits/stdc++.h>

using namespace std;
int q[1111];

int main(void) {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    q[1] = 1;
    for(int i = 2; i < 1111; ++i) {
        if(!q[i]) {
            for(int j = i*2; j < 1111; j += i) {
                q[j] = 1;
            }
        }
    }
    /*
    for(int i = 0; i < 100; ++i) {
        if(!q[i]) cout<<i<<' ';
    }
    cout<<'\n';
    */
    int t;
    cin>>t;
    for(int xx = 0; xx < t; ++xx) {
        int n;
        cin>>n;
        for(int i = 0; i < n; ++i) {
            int w;
            cin>>w;
            int ww = w;
            if(q[w] == 0) {
                vector<int> v;
                while(w) {
                    v.push_back(w%10);
                    w/=10;
                }
                for(int j = 0; j < v.size(); ++j) {
                    if(v[j] != v[v.size()-j-1]) goto ohi;
                }
                cout<<ww<<'\n';
            }
ohi:;
        }
    }


    return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
1000
9
300 988 956 931 116 3 386 202 ...

correct output
3
3
181
919
191
...

user output
3
3
181
919
191
...

Test 2

Verdict: ACCEPTED

input
1
100000
72 247 605 249 10 422 594 490 ...

correct output
191

user output
191