| 23683 | 2026-01-27 17:14:56 | abcd | Szivárványszámok | cpp17 | Compilation error |
#include <bits/stdc++.h>
using namespace std;
const int maxn=76;
ll dp[maxn][10][2][2];
string s;
int n;
ll cnt(int pos,int dig,bool tight,bool up){
if(pos==n)return 1;
if(dp[pos][dig][tight][up]!=-1)return dp[pos][dig][tight][up];
ll res=0;
int lim=tight?s[pos]-'0':9;
for(int i=0;i<=lim;i++){
if(i==dig)res+=cnt(pos+1,i,tight&&i==lim,up);
if(i>dig&&!up)res+=cnt(pos+1,i,tight&&i==lim,false);
if(i>dig&&up)continue;
if(i<dig)res+=cnt(pos+1,i,tight&&i==lim,true);
}
return dp[pos][dig][tight][up]=res;
}
int main(){
cin>>s;
n=s.size();
memset(dp,-1,sizeof(dp));
cout<<cnt(0,0,true,false)-1<<'\n';
}open /var/local/lib/isolate/428/box/a.out: no such file or directory
main.cpp:5:1: error: 'll' does not name a type
5 | ll dp[maxn][10][2][2];
| ^~
main.cpp:9:1: error: 'll' does not name a type
9 | ll cnt(int pos,int dig,bool tight,bool up){
| ^~
main.cpp: In function 'int main()':
main.cpp:26:12: error: 'dp' was not declared in this scope; did you mean 'dup'?
26 | memset(dp,-1,sizeof(dp));
| ^~
| dup
main.cpp:27:11: error: 'cnt' was not declared in this scope; did you mean 'int'?
27 | cout<<cnt(0,0,true,false)-1<<'\n';
| ^~~
| int