1 solutions
-
0
一道很简单的模拟题,唯一的难点就是读取数据
这里直接每输入一个数字就进行一次判断,缺点就是无法在本地测试
#include<bits/stdc++.h> char a, b = '0';//注意,这里b必须是'0' int n = 0, ans[1000010], cnt = 1; int main(){ ans[cnt] = 0; while(std::cin >> a) { n ++; if(a == b) { ans[cnt] ++; } else { b = a; cnt ++; ans[cnt] = 1; } } std::cout << sqrt(n); for(int i = 1; i <= cnt; i ++) { std::cout << " " << ans[i]; } return 0; }
- 1
Information
- ID
- 317
- Time
- 1000ms
- Memory
- 512MiB
- Difficulty
- 1
- Tags
- # Submissions
- 4
- Accepted
- 4
- Uploaded By