mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2025-01-11 23:12:00 +00:00
P2708 硬币翻转
R42118336
This commit is contained in:
parent
b37a3d66b5
commit
486abc676e
19
problem/P2708/P2708.cpp
Normal file
19
problem/P2708/P2708.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
string s;
|
||||
cin >> s;
|
||||
int ans = s.size() - 1;
|
||||
for (int i = 1; i < s.size(); i++) {
|
||||
if (s[i] == s[i - 1]) {
|
||||
ans--;
|
||||
}
|
||||
}
|
||||
if (s[s.size() - 1] == '0') {
|
||||
ans++;
|
||||
}
|
||||
cout << ans << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user