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
TosheX's solution for 300: Integer Pair, written in Java
public class IntegerPair { public int lenghtInt(int a){ int count=0; while (a!=0){ a/=10; count ++; } return count; } public boolean ispair(int a, int b){ String aa, bb; aa = Integer.toString(a); bb = Integer.toString(b); String tmps=""; for (int k=0; k<aa.length()-bb.length()-1; k++){ tmps+="0"; } tmps+=bb; for (int i=0; i<aa.length(); i++){ String tmp=""; for (int j=0; j<aa.length(); j++){ if (j!=i) tmp+=aa.charAt(j); } if (tmp.compareTo(tmps)==0) return true; } return false; } public int count(int N) { int count=0; for (int i=10; i<=N; i++){ if ((lenghtInt(i)-1)>=lenghtInt(N-i)) if (ispair(i, N-i)) count++; } return count; } }