Register
|
Login
Home
News
Competitions
Practice
How to
Rankings
Calendar
Arena
CodeFu 2010
CodeFu'10 Highlights
Jazoon'10 Highlights
Schedule
Rules
Prizes
Results
Competitions
»
Main CodeFu Competitons
»
CodeFu 2010
»
Results
CodeFu 2010 Results
Final Round Results
angel's solution for 300: NumberSequence, written in Java, submitted on 09.05.2010 12:38:59
public class NumberSequence { public int findDigit(int N) { //int[] c = new int[100000]; int temp = 0; int newtemp = 0; int add = 0; //c[0] = 0; int i=1; int sum = 0; for(;i<Integer.MAX_VALUE;i++) { if(i==(int)Math.pow(10, add)) add++; //if(N<=sum+c[i-1]+add) //break; newtemp = temp+add; if(N<=sum+newtemp) break; //c[i]=c[i-1]+add; //sum += c[i]; temp=newtemp; sum += temp; } int k = N-sum-1; String asd = ""; for(int j=1;j<=i;j++) { asd = asd + String.valueOf(j); if(j>k) break; } return Integer.valueOf(String.valueOf(asd.charAt(k))); } }