-
Notifications
You must be signed in to change notification settings - Fork 0
/
575.java
64 lines (49 loc) · 1.4 KB
/
575.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package apr;
import java.io.*;
import java.util.*;
import java.lang.*;
public class Main {
public static void main(String[] args) throws Exception {
try {
new uva.Solver().Solution();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
class uva {
protected static class Solver {
String str;
protected void Solution() throws IOException {
while (scanner.hasNext()) {
str = scanner.next();
if(str==null) continue;
if (str.equals("0")) {
break;
}
int decimalNumber = 0;
//System.out.println(str.charAt(0)-'0');
for (int i = str.length() - 1, k = 1; i >= 0; i--, k++) {
decimalNumber += ((int)str.charAt(i)-'0')*(Math.pow(2, k)-1);
}
System.out.println(decimalNumber);
}
scanner.close();
out.close();
}
}
/*
* output class
*/
// private static DataOutputStream out = new DataOutputStream(System.out);
private static PrintWriter out = new PrintWriter(System.out, true);
/*
* Input class
*/
// private static BufferedReader scanner = new BufferedReader(new
// InputStreamReader(System.in));
// private static DataInputStream scanner = new DataInputStream(System.in);
private static Scanner scanner = new Scanner(System.in);
//private static Scanner scanner = fileFactory.scanner();
//private static BufferedReader scanner = fileFactory.bufferedRader();
}