Code Submission Evaluation System Login

HIIT Open 2016

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

Tasks | Messages | Scoreboard | Statistics


CSES - HIIT Open 2016 - Results
History
2016-05-28 11:40:33
2016-05-28 11:36:43
2016-05-28 11:35:31
2016-05-28 11:32:35
2016-05-28 11:29:37
2016-05-28 11:26:43
Task:Interesting number
Sender:Oispa Kaljaa
Submission time:2016-05-28 11:40:33
Language:C++
Status:READY
Result:ACCEPTED

Test results

testverdicttime (s)
#1ACCEPTED0.10 / 1.00details
#2ACCEPTED0.11 / 1.00details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:31:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j = 0; j < is.length()/2; j++){
                                    ^

Code

#include <bits/stdc++.h>

using namespace std;

string ints(int n){
  stringstream ss;
  ss << n;
  return ss.str();
}  
int main(){
  cin.sync_with_stdio(0);
  cin.tie(0);
  int tests; cin >> tests;
  int prim[101010] = {0};
  prim[2] = 1;
 
  for(int i = 3; i <= 100000; i+=2){
      bool g = true;
      for(int j = 2; j*j <= i ; j++){
	  if(i%j == 0){
	    g = false;
	    break;
	  }
      }
      prim[i] = g;
  }
  int pal[101010] = {0};
  for(int i = 1; i <= 100000; i++){
    string is = ints(i);
    bool g = true;
    for(int j = 0; j < is.length()/2; j++){
	if(is[j] != is[is.length()-1-j])
	  g = false;
    }
    
    pal[i] = g;
    
  }
  int a[101010];
  while(tests--){
      int n; cin >> n;
      
      for(int i = 0; i < n; i++){
	cin >> a[i];
	
      }
      for(int i = 0; i < n; i++){
	if(prim[a[i]] && pal[a[i]]){
	    cout << a[i] << endl;
	    break;
	}
      }
	
  }
  return 0;
}

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