2 条题解
-
0
按题意直接模拟即可。
AC code:
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int ans = 0; int n = s.size(); for (int i = 0; i <= n - 2; i++) { if (s[i] == 'g' && s[i+1] == 'j') { ans++; } } if (ans == 0) { cout << 0 << endl; } else { string result = "1" + to_string(ans - 1); string f; for (char c : result) { if (c != '0') { f += c; } } if (f.empty()) { cout << 0 << endl; } else { cout << f << endl; } } return 0; }
- 1
信息
- ID
- 125
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 1
- 标签
- 递交数
- 4
- 已通过
- 3
- 上传者