Submission #1867008
Source Code Expand
#include<bits/stdc++.h> using namespace std; const int N=5e5+10; char s[N];int n; int main() { gets(s+1); n=strlen(s+1); for (int i=1;i<=n;i++) s[i]-='0'; s[n+1]=127; int ans=0; for (int p=1;p<=n;){ ans++; for (int i=p,now=0;i<=n;i++){ now=max(now,(int)s[i]); int j=i; while (s[j]==now) j++; if (s[j]<now){ now--; s[i]=0; int j=n; while (s[j]==9) s[j--]=0; s[j]++; break; } else{ for (;i<j;s[i++]=0); i--; } } while (!s[p]&&p<=n) p++; } printf("%d\n",ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Increasing Numbers |
User | FoolMike |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 576 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:7:10: error: ‘gets’ was not declared in this scope gets(s+1); ^