QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#283854 | #6300. Best Carry Player 2 | FHQY_WWW# | WA | 0ms | 3620kb | C++20 | 1.6kb | 2023-12-15 16:51:03 | 2023-12-15 16:51:04 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define double long double
#define lowbit(x) x&(-x)
#define fastios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define endl '\n'
#define el puts("")
#define udm unordered_map<int,int>
#define set_0(a) memset(&a,0,sizeof(a))
#define set_unint(a) memset(&a,-1,sizeof(a))
using namespace std;
//define_var
const int M=2e5+9,inf=1e18;
int s1[30],s2[30],p[30];
//define_var
//function_begin
int read()
{
int x=0,f=1;
char c=getchar();
while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
return x*f;
}
void write(int x)
{
if(x<0) putchar('-'),x=-x;
if(x>9) write(x/10);
putchar(x%10+'0');
}
void pri()
{
int ps=-1;
for(int i=29;i>=0;i--)
{
if(s2[i])
{
ps=i;
break;
}
}
if(ps==-1)
{
cout<<1<<endl;
return;
}
for(int i=ps;i>=0;i--)
cout<<s2[i];
cout<<endl;
}
bool judge(int w,int k)
{
memset(s2,0,sizeof(s2));
for(int i=0;i<30;i++)
s1[i]=p[i];
int pos=0;
for(int i=w;i<30;i++)
{
if(pos<k)
{
if(s1[i]==0)
return false;
s2[i]=max(0ll,10-s1[i]);
s1[i+1]++;
pos++;
}
else
{
s2[i]=0;
if(s1[i]>=10)
s1[i+1]++,pos++;
}
}
if(pos==k)
return true;
return false;
}
//function_end
//solve_begin
void solve()
{
int x,k;
cin>>x>>k;
memset(p,0,sizeof(p));
for(int i=0;x;i++)
p[i]=x%10,x/=10;
for(int i=0;i<20;i++)
{
if(judge(i,k))
{
pri();
return;
}
}
cout<<-1<<endl;
}
//solve_end
//main_begin
signed main()
{
fastios
int T=1;
cin>>T;
while(T--)
solve();
}
//main_end
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3620kb
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: 3564kb
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 99999000010000000000 9999910000 9999901000 9999900100 9999900010 9999900001 9000009999900001 99000009999900001 999000009999900001 -1 1
result:
wrong answer 1st lines differ - expected: '100000', found: '1'