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
peceps's solution for 400: Square Count, written in Java
public class SquareCount { /** * @param args */ public static void main(String[] args) { SquareCount count = new SquareCount(); System.out.println(count.pos(3223)); } public int pos(int N) { int[] a = new int[N+1]; int aCount = 0; int cc = 10; if(N<3223332) cc = 50; if(N<200000) cc = 130; if(N<40000) cc = 200; if(N<10000) cc = 500; if(N<3000) cc = 1500; if(N<1000) cc = 3000; int[] ps = new int[cc]; int psCount = 0; int i = 1; while (true) { i++; ps[psCount++] = i * i; if (psCount == ps.length) break; } for (int k = 1; ; k++) { boolean isGood = true; for (int j = 0; j < ps.length; j++) { if(ps[j]!=0) if (k % ps[j] == 0) { isGood = false; break; } } if(isGood) { a[aCount++] = k; } if(aCount==N) { break; } } return a[N-1]; } boolean isOK(int x, int ps) { if ((x % ps) == 0) return false; else return true; } }