結果
問題 | No.884 Eat and Add |
ユーザー |
![]() |
提出日時 | 2019-09-13 21:53:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 1,000 ms |
コード長 | 600 bytes |
コンパイル時間 | 1,651 ms |
コンパイル使用メモリ | 167,552 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-04 04:11:20 |
合計ジャッジ時間 | 2,305 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define modulo 1000000007#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)#define Inf 100000000int main(){string S;cin>>S;reverse(S.begin(),S.end());int ans = 0;for(int i=0;i<S.size();i++){if(i==S.size()-1){if(S[i]=='1')ans++;continue;}if(S[i]=='0')continue;if(S[i+1]=='0'){ans++;continue;}int x = i;while(true){if(x==S.size()){S+='1';break;}if(S[x]=='0'){S[x]='1';break;}S[x]='0';x++;}ans++;}cout<<ans<<endl;return 0;}