-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTea01.java
More file actions
35 lines (30 loc) · 806 Bytes
/
Tea01.java
File metadata and controls
35 lines (30 loc) · 806 Bytes
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
package algorithm.huawei;
import java.util.Scanner;
/**
* @Author: eric
* @Date: 2022/4/23 11:03 上午
*/
public class Tea01 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String[] str = in.nextLine().split(",");
String s = "";
for (String st : str) {
s += st;
}
String[] newStr = s.split("0");
int count = 0;
for (int i = 0; i < newStr.length; i++) {
int length = newStr[i].length();
if (length == 0) {
continue;
}
if (length % 3 != 0) {
count += (length - length % 3) / 3 + 1;
} else {
count += length / 3;
}
}
System.out.println(count);
}
}