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
nikuco's solution for 300: Integer Pair, written in Java
public class IntegerPair { public int count(int N) { int k = 0; int cif; int[] fakt = {1, 10, 100, 1000, 10000, 100000, 1000000}; for (int i = 10; i<=N; i++) { String s = ""+i; //System.out.println(s+":"); int dolz = s.length(); for (int ind=1; ind < dolz-1; ind++) { String del1 = s.substring(0, ind); String del2 = s.substring(ind+1, dolz); //System.out.println(s+": "+del1+" "+del2); int broj1 = Integer.parseInt(del1); int broj2 = Integer.parseInt(del2); int broj = broj1*fakt[ind]+broj2; if (broj + i == N) k++; } String prvo = s.substring(1, dolz); int broj = Integer.parseInt(prvo); if (broj + i == N) k++; String posl = s.substring(0, dolz-1); broj = Integer.parseInt(posl); if (broj + i == N) k++; } return k; } }