(SPOJ) 842 - Torres de Hanói - Solução
import java.io.*;
import java.util.*;
class Main {
public static void main(String[] args) throws NumberFormatException, IOException {
Main processando = new Main();
processando.processa();
System.exit(0);
}
void processa() throws NumberFormatException, IOException {
String line = "";
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int contador = 0;
while ((line = br.readLine()) != null) {
StringTokenizer tokenizer = new StringTokenizer(line);
int valor = Integer.valueOf(tokenizer.nextToken());
if (valor == 0) {
return;
}
contador++;
System.out.println("Teste " + contador + "\n" + (int)(Math.pow(2,valor)-1) + "\n");
}
return;
}
}
import java.util.*;
class Main {
public static void main(String[] args) throws NumberFormatException, IOException {
Main processando = new Main();
processando.processa();
System.exit(0);
}
void processa() throws NumberFormatException, IOException {
String line = "";
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int contador = 0;
while ((line = br.readLine()) != null) {
StringTokenizer tokenizer = new StringTokenizer(line);
int valor = Integer.valueOf(tokenizer.nextToken());
if (valor == 0) {
return;
}
contador++;
System.out.println("Teste " + contador + "\n" + (int)(Math.pow(2,valor)-1) + "\n");
}
return;
}
}
Comments
Post a Comment