| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
S.O.S Help Problem World Cup NoiseI 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator