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
aleksp's solution for 400: Square Count, written in Java
public class SquareCount { static int niza[]; static int count; public static void napolni() { niza=new int[1000000]; int br=2; int i=0; while (br*br<1000000000) { niza[i]=br*br; i++; br++; } count=i; } public static int sleden(int N) { boolean stop=false; while (!stop) { N++; int i; boolean da=true; for (i=0; i<count/2; i++) { if (niza[i]>N) break; if (N%niza[i]==0) { da=false; break; } } if (da) { return N; } } return 0; } public static int pos(int N) { napolni(); int broj=1; for (int i=1;i<N; i++) broj=sleden(broj); return broj; } }