CSES - HIIT Open 2016 - Results
Submission details
Task:Interesting number
Sender:zah
Submission time:2016-05-28 12:19:13 +0300
Language:C++
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.06 sdetails
#2ACCEPTED0.06 sdetails

Code

#include <iostream>
using namespace std;
//ios_base::sync_with_stdio(0);
//cin.tie(0);
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
int n;
int x;
int alkuluvut[1001] = {};
alkuluvut[1] = 1;
for(int i=2; i<100; i++) {
for(int j=i*i; j<1001; j+=i) alkuluvut[j]=1;
}
for(int i=0; i<t; i++) {
cin >> n;
for(int j=0; j<n; j++) {
cin >> x;
if(x>99){
if(alkuluvut[x]==0){
if(x/100==x%10){ //palindromi
cout << x << "\n";
//break;
}
}
}
else if(x>9){
if(alkuluvut[x]==0){
if(x/10==x%10){
cout << x << "\n";
//break;
}
}
} else {
if(alkuluvut[x]==0){
cout << x << "\n";
//break;
}
}
}
}
}

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