ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1564. Counting Ones

the best way to SUCCESS, it's not Solution but 99% to test Sol
Posted by Erko 13 Nov 2008 15:56
NEXT CODE IS NOT AC SOLUTION
but it a way to test your Solution


next class run with command: "java tester >test.txt"
then you can run your solution and compare your answers with this tester's
But you cant test some tests where n>30000, therefore
try to think and about it.
Good luck to TEST, I AC))
////////////////////////tester.java///////////////////////////
import java.io.*;
import java.util.*;

public class tester{
 public static void main(String[] args){
  int s=0,ts=0;
  int t;
  int a[]=new int[30000];
  for(int i=0;i<30000;i++){
   a[i]=0;
  }
  for(int i=1;i<=50000;i++){
   ts=s;
   t=i;
   while(t>=10){
    if(t%10==1){
     s++;
    }
    t/=10;
   }
   if(t==1){
    s++;

   }
   if(ts!=s)
    a[s-1]=i;
  }

  for(int i=0;i<30000;i++){
   if(a[i]!=0)
    System.out.println((i+1) + " "+ a[i]);
   else
    System.out.println((i+1)+ " " +"Petr lies");
  }
 }
}

////////////////////////end///////////////////////////