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
dimitar's solution for 400: Square Count, written in Java
public class SquareCount { public int pos(int n) { int ret = n; int[] last = new int[10000]; int t = (int)Math.sqrt(n*2); boolean change; while (true) { change = false; for (int i=2; i<t; i++) { int x = i*i; while ((ret-last[i])/x > 0) { change = true; int old = ret; ret += (ret-last[i]) / x; last[i] = old - (old%x); } } if (!change) break; } return ret; } }