- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumberCard.java
More file actions
Latest commit
43 lines (37 loc) · 1.04 KB
/
Copy pathNumberCard.java
File metadata and controls
43 lines (37 loc) · 1.04 KB
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
importjava.io.BufferedReader;
importjava.io.IOException;
importjava.io.InputStreamReader;
importjava.util.Arrays;
publicclassMain {
publicstaticvoidmain(String[] args) {
try{
newNumberCard();
}catch(IOExceptione){
e.printStackTrace();
}
}
}
classNumberCard{
publicint[][] cin;
publicStringnum;
publicNumberCard() throwsIOException {
cin = newint[40][2];
cin[0][0] = 1;
BufferedReaderbr = newBufferedReader(newInputStreamReader(System.in));
num = br.readLine();
logic(num, 1);
System.out.println(cin[num.length()-1][0]+cin[num.length()-1][1]);
}
publicvoidlogic(Stringnum, intidx){
if(num.length()<2)return;
intn = Integer.parseInt(num.substring(0,2));
if(n==0)return;
if(0<n%10){
cin[idx][0] = cin[idx-1][0] + cin[idx-1][1];
}
if( 10<= n && n <=34){
cin[idx][1] = cin[idx-1][0];
}
logic(num.substring(1), ++idx);
}
}