QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#303544 | #6300. Best Carry Player 2 | ucup-team052# | WA | 0ms | 3756kb | C++23 | 1.3kb | 2024-01-12 18:09:01 | 2024-01-12 18:09:02 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define mod 998244353
#define int __int128
#define inf 0x3f3f3f3f
#define INF ((int)1e19)
inline int read()
{
char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
if(nega==-1) return -ans;
return ans;
}
void print(vector<int> x){for(int i=0;i<(int)x.size();i++) printf("%d%c",x[i]," \n"[i==(int)x.size()-1]);}
void work()
{
int n=read(),k=read();
vector<int> s;
while(n)
{
s.push_back(n%10);
n/=10;
}
while((int)s.size()<36) s.push_back(0);
int mn=INF;
if(k==0)
{
int pw=1;
for(int i=0;;i++)
{
if(s[i]!=9)
{
printf("%lld\n",(long long)pw);
return ;
}
pw*=10;
}
}
for(int c=0;c<=18;c++)
{
int ans=0;
vector<int> ts=s;
int pw=1;
for(int i=0;i<c;i++) pw*=10;
int tk=k;
for(int i=c;i<(int)ts.size();i++)
{
if(tk) ans+=pw*(10-ts[i]),ts[i+1]++,tk--;
else
{
if(ts[i]==10) ans=INF;
break;
}
pw*=10;
}
mn=min(mn,ans);
}
printf("%lld\n",(long long)mn);
}
signed main()
{
int T=read(); while(T--) work();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3648kb
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: 0ms
memory: 3756kb
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:
100000 10000 1000 100 10 1 900001 9900001 99900001 999900001 10000000000 9999910000 9999901000 9999900100 9999900010 9999900001 9000009999900001 99000009999900001 999000009999900001 900000000000000000 1000000000000000000
result:
wrong answer 11th lines differ - expected: '10000000001', found: '10000000000'