forked from wotjd4305/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswe4789.java
More file actions
69 lines (53 loc) · 1.56 KB
/
swe4789.java
File metadata and controls
69 lines (53 loc) · 1.56 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class swe4789 {
static Boolean P_Arr[];
static ArrayList<Integer> AL = new ArrayList<>();
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
int answer;
//테스트케이스
for(int t=0; t<T; t++) {
String Num = sc.next();
answer = Solution(Num);
System.out.println("#"+ (t+1) + " " + answer);
}
}
public static int Solution(String Num)
{
int answer = 0;
answer = zero_ct(Num);
return answer;
}
public static int zero_ct(String Num)
{
int ct =0;
for(int i=0; i<Num.length();)
{
System.out.println("first" + i);
if( Num.charAt(i) == '0')
{
System.out.println("idx" + i);
i++;
ct++;
//System.out.println("if" + i);
}
else
{
//System.out.println(Integer.parseInt("" + Num.charAt(i)));
int buffer_i = i;
//System.out.println("else" + i);
for(int j =buffer_i;
j < Num.length() && j< (i + Integer.parseInt("" + Num.charAt(j)));
j++)
{
//System.out.println("else - for" + i);
i += Integer.parseInt("" + Num.charAt(j));
}
}
}
return ct;
}
}