Code Submission Evaluation System Login

CSES - HIIT Open 2016

HIIT Open 2016

Contest start:2016-05-28 11:00:00
Contest end:2016-05-28 16:00:00

Task list | Submit code | Submissions | Messages | Scoreboard | Statistics


History
2016-05-28 11:14:02
Task:Interesting number
Sender:Game of Nolife
Submission time:2016-05-28 11:14:02
Status:READY
Result:ACCEPTED

Show test data

Code

#include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;

int pp[2020];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	pp[0]=1;
	pp[1]=1;
	for (int i=2;i<=1000;i++){
		for (int j=2;j*i<=1000;j++){
			pp[j*i]=1;
		}
	}
	int tcs;
	cin>>tcs;
	for (int tc=0;tc<tcs;tc++){
		int n;
		cin>>n;
		for (int i=0;i<n;i++){
			int a;
			cin>>a;
			if (pp[a]==0){
				string lol=to_string(a);
				string asd=lol;
				reverse(lol.begin(), lol.end());
				if (lol==asd){
					cout<<a<<'\n';
				}
			}
		}
	}
}