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
time_bandit's solution for 300: NumberSequence, written in Java, submitted on 09.05.2010 12:50:33
public class NumberSequence { public int findDigit(int N) { long[] niza = new long[90000]; long[] tmp = {0, 9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999}; int n = 1; niza[0] = 1; for (int i = 1; i < niza.length; i++) { if(i >= tmp[n]) n++; niza[i] = niza[i-1] + n; } // for (int i = 0; i < niza.length; i++) { // System.out.println(niza[i] + " " + i); // } int temp = 0; int ii = 0; while(N > 0) { temp = N; N -= niza[ii]; ii++; } StringBuilder st = new StringBuilder(); for (int i = 1; i < 500000; i++) { st.append(i); } int result = st.charAt(temp - 1) - '0'; return result; } /** * @param args */ public static void main(String[] args) { System.out.println(new NumberSequence().findDigit(10001)); // TODO Auto-generated method stub } }