QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#302958 | #6300. Best Carry Player 2 | _fcy_# | WA | 1ms | 3760kb | C++14 | 2.1kb | 2024-01-11 16:07:00 | 2024-01-11 16:07:01 |
Judging History
answer
#include<bits/stdc++.h>
#define int unsigned long long
#define p(a,b) make_pair(a,b)
#define pb push_back
using namespace std;
const int MAXN=5e5+10;
const int mod=1e9+7;
int n,k,a[30];
int cal(int k)
{
//cout<<k<<endl;
int fn0=0,ans=0;
while(a[fn0+1]==0)
{
fn0++;
}
int fs9=fn0+k+1;
//cout<<fn0<<" "<<fs9<<endl;
if(a[fs9]<9)
{
int base=pow(10,fn0);
ans=(10-a[fn0+1])*base;
base*=10;
//cout<<a[fn0+1]<<" "<<ans<<endl;
for(int i=fn0+2;i<=fs9-1;i++)
{
ans+=(9-a[i])*base;
base*=10;
}
return ans;
}
while(a[fs9+1]==9)
{
fs9++;
}
//cout<<"check:"<<fs9<<endl;
int base=pow(10,fs9-k);
ans=0;
//cout<<ans<<endl;
if(a[fs9-k+1]==0)
{
fn0=fs9-k+1;
while(a[fn0+1]==0)
{
fn0++;
}
base=pow(10,fn0);
ans+=base*(10-a[fn0+1]);
base*=10;
for(int i=fn0+2;i<=fs9;i++)
{
ans+=base*(9-a[i]);
base*=10;
}
//cout<<ans<<" "<<fs9<<" "<<fn0<<endl;
return ans+cal(k-(fs9-fn0));
}
ans+=base*(10-a[fs9-k+1]);
//cout<<ans<<endl;
base*=10;
for(int i=fs9-k+2;i<=fs9;i++)
{
ans+=base*(9-a[i]);
base*=10;
}
return ans;
}
void solve()
{
int sn,sk;
cin>>sn>>sk;
if(sk==0)
{
cout<<"1\n";
return;
}
for(int i=1;i<=20;i++)
{
a[i]=0;
}
int tmp=sn,cz=0,cnt=0,flag=0;
while(tmp)
{
cnt++;
a[cnt]=tmp%10;
if(a[cnt]!=0)
{
flag=1;
}
if(flag==0)
{
cnt--;
cz++;
}
tmp/=10;
}
cout<<cal(sk);
for(int i=1;i<=cz;i++)
{
cout<<"0";
}
cout<<endl;
}
signed main()
{
int t;
cin>>t;
while(t--)
{
solve();
}
return 0;
}
/*
6
990090001000 4
*/
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3760kb
input:
4 12345678 0 12345678 5 12345678 18 990099 5
output:
1 54322 999999999987654322 9910
result:
ok 4 lines
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3752kb
input:
21 999990000099999 0 999990000099999 1 999990000099999 2 999990000099999 3 999990000099999 4 999990000099999 5 999990000099999 6 999990000099999 7 999990000099999 8 999990000099999 9 999990000099999 10 999990000099999 11 999990000099999 12 999990000099999 13 999990000099999 14 999990000099999 15 999...
output:
1 10000 1000 100 10 1 900001 9900001 99900001 999900001 10000000001 9999910000 9999901000 9999900100 9999900010 9999900001 9000009999900001 99000009999900001 999000009999900001 99999999999999999900000000000000000 1
result:
wrong answer 1st lines differ - expected: '100000', found: '1'