CSES - HIIT Open 2016 - Results
Submission details
Task:Interesting number
Sender:Barely Div 1
Submission time:2016-05-28 11:21:32 +0300
Language:C++
Status:READY
Result:
Test results
testverdicttime
#10.04 sdetails
#20.05 sdetails

Code


#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;


bool ok(int i) {
	string s = to_string(i);
	string s2 = s;
	reverse(s2.begin(), s2.end());
	if (s != s2) return false;
	if (i <= 2) return true;
	for (int j = 2; j < i; j++) {
		if ((i % j) == 0) {
			return false;
		}
	}
	return true;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int t; cin >> t;
	vector<bool> oks(1001);
	for (int i = 1; i<=1000; i++) {
		if (ok(i)) oks[i] = true;
	}
	while (t--) {
		int n; cin >> n;
		while (n--) {
			int num; cin >> num;
			if (oks[num]) {
				cout << num << "\n";
			}
		}

	}


}






Test details

Test 1

Verdict:

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:

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

correct output
191

user output
1
1
1
1
1
...