Submission #1120350

#TimeUsernameProblemLanguageResultExecution timeMemory
1120350MoonnPalindrome-Free Numbers (BOI13_numbers)C++17
52.50 / 100
1097 ms512 KiB
#pragma GCC optimize("O3") #include<bits/stdc++.h> #define ll long long #define endl "\n" #define AI ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); using namespace std; int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); ll a,b,s=0,z=0,i,j; cin>>a>>b; ll tt[19]; tt[0]=1; for(i=1;i<19;i++) tt[i]=tt[i-1]*10; if(a<tt[1]) a=tt[1]; //cout<<a<<' '<<b<<endl; while(a<=b) { // cout<<a<<' '; string x=to_string(a); ll z=0,eded=x[0]-'0'; bool bo=true; for(i=1;i<x.size();i++) { if(x[i]==x[i-1]) { bo=false; z=x.size()-i-1; j=i; while(x[j]=='9') { j--; z++; eded/=10; if(j==-1) break; } if(j==-1) eded=tt[z]; else eded=eded*(tt[z+1])+(x[j]-'0'+1)*tt[z]; break; } if(i>1 and x[i]==x[i-2]) { bo=false; z=x.size()-i-1; j=i; while(x[j]=='9') { j--; z++; eded/=10; if(j==-1) break; } if(j==-1) eded=tt[z]; else eded=eded*(tt[z+1])+(x[j]-'0'+1)*tt[z]; break; } eded*=10; eded+=x[i]-'0'; } // cout<<eded<<"EDED "; // if(bo) // cout<<a<<' '<<s+1<<endl; if(bo) a=eded+1; else a=eded; if(bo) s++; // cout<<s<<"say\n"; } cout<<s<<endl; } /* [ */

Compilation message (stderr)

numbers.cpp: In function 'int main()':
numbers.cpp:26:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for(i=1;i<x.size();i++)
      |                 ~^~~~~~~~~
numbers.cpp:11:16: warning: unused variable 'z' [-Wunused-variable]
   11 |     ll a,b,s=0,z=0,i,j;
      |                ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...