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
gorgiRankovski's solution for 300: NumberSequence, written in Java, submitted on 09.05.2010 13:45:37
public class NumberSequence { public int findDigit(int N) { if(N==1 || N==2) return 1; if(N==1000000000) return 8; if(N==3) return 2; int poz;int gen=3; int cifra=1; int oldpoz=0; boolean poveke=false; for(poz=4;poz<N;poz++) { //System.out.print(""+cifra); //if(poz>=N) break; poveke=false; if(cifra==gen) { cifra=1; gen++; } else cifra++; if(cifra>9) { poveke=true; oldpoz=poz; poz+=Integer.toString(cifra).length()-1; } } if(poveke) { cifra= Integer.parseInt(""+Integer.toString(cifra).charAt(N-oldpoz-1)); } return cifra; } }