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
dsmilkov's solution for 300: Integer Pair, written in Java
public class IntegerPair { public int count(int N) { int up = N; int down = 0; int count = 0; for (int i = 0; i <= N/2; i++) { String strUp = String.valueOf(up); String strDown = String.valueOf(down); int a = strUp.length() - strDown.length(); if(a>0) if(isSpecial(strUp,strDown,a)) { count++; } up--; down++; } return count; } public boolean isSpecial(String up,String down,int a) { for (int i = 0; i < a - 1; i++) { down = "0" + down; } char chars[] = up.toCharArray(); int len = chars.length; for (int i = 0; i < chars.length; i++) { String tmp = ""; for (int j = 0; j < chars.length; j++) { if(j!=i) tmp+=chars[j]; } if(tmp.equals(down)) return true; } return false; } public static void main(String[] args) { IntegerPair test = new IntegerPair(); System.out.println(test.count(1000000)); } }