Register
|
Login
Home
News
Competitions
Practice
How to
Rankings
Calendar
Arena
CodeFu 2007
CodeFu'07 Highlights
Jazoon'07 Highlights
Schedule
Rules
Prizes
Results
Competitions
»
Main CodeFu Competitons
»
CodeFu 2007
»
Results
CodeFu 2007 Results
CodeFu Final Round Results
Iterator's solution for 400: Square Count, written in Java
public class SquareCount { public static int pos(int N) { int kv[] = new int[10000]; for(int i=2;i<10000;i++){ kv[i-2] = i*i; } int broevi[] = new int[N]; int kec = 1; boolean treba = true; int sl=0; while(sl<N){ treba = true; int brw = 0; boolean semafor = true; while(semafor){ if(kv[brw] > kec ){semafor = false;} brw++; }//*/ for(int j=0;j<brw;j++){ if((kec%kv[j] == 0) || (kec%4 == 0) || (kec%9 == 0) || (kec%25 == 0) || (kec%36 == 0)) {treba = false; break;} }//end j*/ if(treba){ //broevi[sl] = kec; sl++; }//end if treba //else{sl--;} kec++; }//end for return kec-1;//broevi[N-1]; }//end pos }