# HIIT Open 2016

 Start: 2016-05-28 11:00:00 End: 2016-05-28 16:00:00

CSES - HIIT Open 2016 - Results
History
2016-05-28 11:45:25
 Task: Interesting number Sender: Anonyymit Algoritmistit Submission time: 2016-05-28 11:45:25 Language: C++ Status: READY Result: ACCEPTED

## Test results

 test verdict time (s) #1 ACCEPTED 0.05 / 1.00 details #2 ACCEPTED 0.06 / 1.00 details

## Code

```#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

bool palindrome(int x) {
stringstream s;
s << x;
string s1;
s >> s1;
string s2(s1.rbegin(), s1.rend());
return s1 == s2;
}

bool prime(int x) {
if (x == 1) return false;
if (x == 2) return true;
if ((x % 2) == 0) return false;
for (int i = 3; i*i <= x; i += 2) {
if ((x % i) == 0) return false;
}
return true;
}

int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);

int t;
cin >> t;

for (int i = 0; i < t; ++i) {
int n;
cin >> n;
int v = -1;
for (int j = 0; j < n; ++j) {
int x;
cin >> x;
if (v == -1) {
if (prime(x) && palindrome(x))
v = x;
}
}
cout << v << endl;
}
}```

## Test details

### Test 1

Verdict: ACCEPTED

input
```1000 9 300 988 956 931 116 3 386 202 ... 8 786 850 344 607 258 3 564 795 7 181 300 325 705 512 972 207 6 919 257 176 534 398 536 9 324 811 467 265 688 191 642 17... 5 7 691 423 512 506 5 705 191 300 735 966 10 134 709 407 211 518 815 444 11... 9 794 476 394 244 671 181 466 92... 6 ...```
view   save

correct output
```3 3 181 919 191 7 191 353 181 929 787 727 7 373 313 2 353 383 787 919 ...```
view   save

user output
```3 3 181 919 191 7 191 353 181 929 787 727 7 373 313 2 353 383 787 919 ...```
view   save

### Test 2

Verdict: ACCEPTED

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

correct output
`191`
view   save

user output
`191`
view   save