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 12:19:13
2016-05-28 12:17:45
2016-05-28 12:16:49
2016-05-28 12:15:20
2016-05-28 12:13:46
2016-05-28 12:12:33
2016-05-28 12:11:20
2016-05-28 12:08:38
2016-05-28 12:08:18
2016-05-28 12:06:08
2016-05-28 12:04:53
2016-05-28 12:02:24
2016-05-28 12:00:43
2016-05-28 12:00:07
2016-05-28 11:58:13
2016-05-28 11:56:36
Task:Interesting number
Sender:zah
Submission time:2016-05-28 12:19:13
Status:READY
Result:ACCEPTED

Show test data

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;                    
                }
            }
        }
    }
}