Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

S.O.S Help Problem World Cup Noise

Posted by chiperortizc at 2007-06-12 06:30:05
I Get Time Limit!!!
import java.io.*;

public class Main {
    public static int x = 0;
    public static int Mostrar (int Num, int a)
    {
          String Opc = "11";
          String Cad = "";
          int Res = 0;
          boolean Sw = (a != 0);
          while (true)
          {
             Cad = Integer.toBinaryString(a);
             a++;
             if (Cad.length()<=Num)                 
             {    
               if (Cad.indexOf(Opc) == -1)   
                  Res++;                                                            
             }  
             else
                 break;
          }             
           x = a-1; 
       return Res;   
    }
    
    public static void main(String[] args)
    {
       try
       {
        //BufferedReader Leer = new BufferedReader (new InputStreamReader (System.in));
        BufferedReader Leer = new BufferedReader (new FileReader (new File ("Hola.txt"))); 
         long Acu = 0,Opc = 0; int Ant = 1;
         int n = Integer.parseInt (Leer.readLine());
         n--;
         for (int i=1;i<=n;i++)
         {
            int Num = Integer.parseInt (Leer.readLine());
            System.out.println ("Scenario #"+i+":");
            if (Num > Ant)
            {
               System.out.println ("Ayuda"); 
               int d = Mostrar(Num,x);
               Acu  += d;
               System.out.println (Acu);
            }  
            else
            { 
              Acu = Mostrar(Num,0);   
              System.out.println (Acu);
            }   
            System.out.println();           
            Ant = Num;
         }    
       }
       catch(Exception e)
       {  }
    }    
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator