ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#164763 | #2909. number | louhao088 | 100 | 935ms | 2796kb | C++11 | 1.5kb | 2022-11-05 18:41:53 | 2022-11-05 18:41:54 |
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=2e5+5,M=2e5+5,mod=998244353,B=1e5;
inline int read(){
char ch=getchar();bool f=0;int x=0;
for(;!isdigit(ch);ch=getchar())if(ch=='-')f=1;
for(;isdigit(ch);ch=getchar())x=(x<<1)+(x<<3)+(ch^48);
if(f==1){x=-x;}return x;
}
void print(int x){
static int a[55];int top=0;
if(x<0) putchar('-'),x=-x;
do{a[top++]=x%10,x/=10;}while(x);
while(top) putchar(a[--top]+48);
}
int n,m,x,y,f[15][105][105],pw[15],fac[15],s[maxn];
int get(int x){return s[x/B]+s[x%B];}
void solve(int x,int y){
y++;
int a=x/100,b=x%100,c=y/100,d=y%100,p=0;
if(!a&&c)a=1,b=f[0][0][b];
while(a<c){
while(a%pw[p+1]==0)p++;
if(a+pw[p]>c)break;
b=f[p][get(a)][b];a+=pw[p];
}
while(1){
while(p>=0&&a+pw[p]>c)p--;
if(p==-1)break;
b=f[p][get(a)][b];a+=pw[p];
}
while(b<d){b+=get(b+a*100);}
printf("%lld\n",a*100+b);
}
signed main(){
//freopen("1.in","r",stdin);
//freopen(".out","w",stdout);
pw[0]=1;m=read();
for(int i=1;i<=B;i++)s[i]=s[i/10]+i%10;
for(int i=1;i<=10;i++)pw[i]=pw[i-1]*10;
for(int j=0;j<100;j++)
for(int k=99;k>=0;k--){int z=j+k+s[k];
if(z>=100)f[0][j][k]=z%100;
else f[0][j][k]=f[0][j][z];
}
for(int i=1;i<10;i++)
for(int j=0;j<100;j++)
for(int k=99;k>=0;k--){f[i][j][k]=k;
for(int l=0;l<10&&j+l<100;l++)
f[i][j][k]=f[i-1][j+l][f[i][j][k]];
}
for(int i=1;i<=m;i++){
x=read(),y=read(),solve(x,y);
}
return 0;
}
Details
小提示:点击横条可展开更详细的信息
Subtask #1:
score: 20
Accepted
Test #1:
score: 20
Accepted
time: 157ms
memory: 2796kb
input:
500000 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 ...
output:
2 4 4 8 8 8 8 16 16 16 16 16 16 16 16 23 23 23 23 23 23 23 28 28 28 28 28 38 38 38 38 38 38 38 38 38...
result:
ok 500000 lines
Test #2:
score: 0
Accepted
time: 278ms
memory: 2792kb
input:
500000 92 99927 119 99453 481 99268 29 99908 267 99547 835 99500 955 99099 734 99774 306 99883 729 9...
output:
99941 99454 99274 99941 99555 99520 99112 99775 99900 99657 99978 100010 99545 99245 99775 99907 997...
result:
ok 500000 lines
Subtask #2:
score: 25
Accepted
Test #3:
score: 25
Accepted
time: 197ms
memory: 2796kb
input:
500000 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 ...
output:
2 4 4 8 8 8 8 16 16 16 16 16 16 16 16 23 23 23 23 23 23 23 28 28 28 28 28 38 38 38 38 38 38 38 38 38...
result:
ok 500000 lines
Subtask #3:
score: 25
Accepted
Test #4:
score: 25
Accepted
time: 3ms
memory: 2796kb
input:
50 4587480273 4587480273 428862505 500400481 6920415626 7358620174 7787875953 7787884613 4542304779 ...
output:
4587480321 500400482 7358620210 7787884620 4542307848 4676070172 909798356 3555627285 9508855574 511...
result:
ok 50 lines
Subtask #4:
score: 30
Accepted
Test #5:
score: 30
Accepted
time: 300ms
memory: 2792kb
input:
500000 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 ...
output:
2 4 4 8 8 8 8 16 16 16 16 16 16 16 16 23 23 23 23 23 23 23 28 28 28 28 28 38 38 38 38 38 38 38 38 38...
result:
ok 500000 lines