From 486abc676e5f648d83ba3a07daa7be941e60e210 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Wed, 18 Nov 2020 18:08:10 +0800 Subject: [PATCH] =?UTF-8?q?P2708=20=E7=A1=AC=E5=B8=81=E7=BF=BB=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R42118336 --- problem/P2708/P2708.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 problem/P2708/P2708.cpp diff --git a/problem/P2708/P2708.cpp b/problem/P2708/P2708.cpp new file mode 100644 index 00000000..1c755b59 --- /dev/null +++ b/problem/P2708/P2708.cpp @@ -0,0 +1,19 @@ +#include + +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; +}