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
carevski's solution for 300: Integer Pair, written in Java
import java.util.*; public class IntegerPair { public static int cifri(int j){ int count = 0; for(int k = j;k>0; k/=10 ) count++; return count; } public static int count(int N){ int brojac = 0; int cif = cifri(N); LinkedList postojat = new LinkedList<Integer> (); int start; if(Integer.toString(N).charAt(0) == '1') start = N -((int)Math.pow(10, cif-2)); else start = N -((int)Math.pow(10, cif-1)); //System.out.println(start); for(int i = start;i<=N;i++){ int brCifri = cifri(i); String niz = Integer.toString(i); for(int k=0;k<brCifri;k++){ int novBroj = 0; int ste = brCifri-2; for(int p=0; p<brCifri;p++){ if(k!=p){ novBroj += Math.pow(10, ste)*(((int)niz.charAt(p))-48); ste--; } } if(novBroj+i == N && !postojat.contains(novBroj) ){ postojat.add(novBroj); brojac++; } } } return brojac; } public static void main(String[] args) { System.out.println(IntegerPair.count(100)); } }