正文
增加 5 行删除 5 行
20 行未改动212223242526272829303132333435363738392 行未改动42434445464748495051525354555699 行未改动20 行未改动```cpp#include<bits/stdc++.h>#define ll long longusing namespace std;ll read(){ll x=0,f=1;char ch=getchar();while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}while('0'<=ch&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return f*x;}ll L,R;ll f[15][15],a[15],m=0;ll dfs(ll i, ll pre, bool flag){if(i==0)return 1;// 只有一个数就返回一个答案if(flag==0&&f[i][pre]!=-1)return f[i][pre];// 记忆化,要求当前没有顶着上界且答案已经统计过ll sum=0,lim=(flag?a[i]:9);// 第 i 位的上界,如果是卡着上界上界就是 a[i],否则就是 92 行未改动sum+=dfs(i-1,x,(flag==1&&x==lim));// 累积答案}if(flag==0)f[i][pre]=sum;// 没有顶着上界才能记录return sum;}ll calc(ll x){if(!x)return 1;m=0;while(x)a[++m]=x%10,x/=10;// 转成数组更好处理return dfs(m,0,1);}int main(){memset(f,-1,sizeof(f));while(1){L=read(),R=read();99 行未改动20 行未改动212223242526272829303132333435363738392 行未改动42434445464748495051525354555699 行未改动20 行未改动```cpp#include<bits/stdc++.h>#define ll long longusing namespace std;ll read(){ll x=0,f=1;char ch=getchar();while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}while('0'<=ch&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return f*x;}ll L,R;ll f[15][15],a[15],m=0;ll dfs(ll i, ll pre, bool flag){if(i==0)return 1;// 只有一个数就返回一个答案if(flag==0&&f[i][pre]!=-1)return f[i][pre];// 记忆化,要求当前没有顶着上界且答案已经统计过ll sum=0,lim=(flag?a[i]:9);// 第 i 位的上界,如果是卡着上界上界就是 a[i],否则就是 92 行未改动sum+=dfs(i-1,x,(flag==1&&x==lim));// 累积答案}if(flag==0)f[i][pre]=sum;// 没有顶着上界才能记录return sum;}ll calc(ll x){if(!x)return 1;m=0;while(x)a[++m]=x%10,x/=10;// 转成数组更好处理return dfs(m,0,1);}int main(){memset(f,-1,sizeof(f));while(1){L=read(),R=read();99 行未改动