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
Gocepp's solution for 300: NumberSequence, written in Java, submitted on 09.05.2010 14:14:34
public class NumberSequence { public int izdvoj(int a,int b) { for (int i=0; i<b; i++) a/=10; return a%10; } public int findDigit(int N) { int br=0; int rez=0; int []tezina=new int[10]; tezina[0]=10; tezina[1]=190; tezina[2]=2890; tezina[3]=38890; tezina[4]=488890; tezina[5]=5888890; tezina[6]=68888890; tezina[7]=100000000; int j=0; int temp; while (br<N) { br=tezina[j]; j++; } switch (j) { case 0: { rez=N; break; } case 1: { temp=N/10; if (N%2==0) rez=temp; else rez=N%10; break; } case 2: { temp=(N-190)/3; rez=izdvoj((temp+100),(N-190)%3); break; } case 3: { temp=(N-2890)/4; rez=izdvoj((temp+1000),(N-2890)%4); break; } case 4: { temp=(N-38890)/4; rez=izdvoj((temp+10000),(N-38890)%4); break; } case 5: { temp=(N-488890)/5; rez=izdvoj((temp+100000),(N-488890)%4); break; } case 6: { temp=(N-5888890)/6; rez=izdvoj((temp+1000000),(N-5888890)%4); break; } case 7: { temp=(N-68888890)/7; rez=izdvoj((temp+1000000),(N-68888890)%4); break; } } return rez; } }