제출 #779888

#제출 시각아이디문제언어결과실행 시간메모리
779888vjudge1Palindrome-Free Numbers (BOI13_numbers)C++17
100 / 100
1 ms340 KiB
#include<bits/stdc++.h> using namespace std; using ll=long long; vector<int> digit; ll dp[20][2][19][19]; ll solve(int id,int flag,int last1,int last2,int check){ //cout<<last1<<" "<<last2<<"#"<<endl; if(id==digit.size()&&check==1) return 1; if(id==digit.size()&&check==0) return 0; if(dp[id][flag][last1][last2]!=-1) return dp[id][flag][last1][last2]; int pos; if(flag==1){ pos=9; } if(flag==0){ pos=digit[id]; } ll res=0; for(int i=0;i<=pos;++i){ int preflag=flag; int prelast1=last1; int prelast2=last2; int precheck=check; if(i!=pos){ preflag=1; } bool csgt=false; if(last1==18&&last2==18){ if(i==0){ csgt=true; } } if(i==prelast1){ precheck=false; } if(i==prelast2){ precheck=false; } //cout<<prelast1<<" "<<prelast2<<" "<<i<<"#"; if(precheck==true){ prelast1=i; prelast2=last1; if(csgt==true){ prelast1=18; prelast2=18; } //cout<<prelast1<<" "<<prelast2<<" "<<i<<"#"; res+=solve(id+1,preflag,prelast1,prelast2,precheck); } } return dp[id][flag][last1][last2]=res; } ll get(ll a){ if(a==-1) return 0; digit.clear(); while(a>0){ digit.push_back(a%10); a/=10; } reverse(digit.begin(),digit.end()); // for(auto item:digit) cout<<item<<" "; memset(dp,-1,sizeof(dp)); ll kqua=solve(0,0,18,18,1); return kqua; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); ll a; ll b; cin>>a>>b; //cout<<get(0); //cout<<get(b)<<" "<<get(a-1); ll kqua=get(b)-get(a-1); cout<<kqua; }

컴파일 시 표준 에러 (stderr) 메시지

numbers.cpp: In function 'll solve(int, int, int, int, int)':
numbers.cpp:8:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |  if(id==digit.size()&&check==1) return 1;
      |     ~~^~~~~~~~~~~~~~
numbers.cpp:9:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |  if(id==digit.size()&&check==0) return 0;
      |     ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...