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
sqrt_x's solution for 300: Integer Pair, written in Java
public class IntegerPair { public int count(int N) { int count = 1; int x, y; int n1 = N; int m = 1; String sx, sy; while (n1 > 10) { n1 /= 10; m *= 10; } //System.out.println(n + " " + m); for (int i = N - m; i < N; i++) { x = i; y = N - i; sx = "" + x; sy = "" + y; if (ok(sx, sy)) count++; } return count; } private boolean ok(String s1, String s2) { String temps; for (int i = 0; i < s1.length(); i++) { temps = ""; for (int j = 0; j < s1.length(); j++) if (i != j) temps += s1.charAt(j); if (temps.equals(s2)) return true; } return false; } }