QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#279887#6300. Best Carry Player 2forget-star#WA 0ms3740kbC++201002b2023-12-09 11:18:032023-12-09 11:18:04

Judging History

你现在查看的是最新测评结果

  • [2023-12-09 11:18:04]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3740kb
  • [2023-12-09 11:18:03]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define fr(i,a,b) for(int i(a),end##i(b);i<=end##i;i++)
#define fd(i,a,b) for(int i(a),end##i(b);i>=end##i;i--)
#define mk make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
using namespace std;
int t,x,k;
int p[100],ans[100];
void out(){
	int flag=0;
	fd(i,50,1){
		flag|=(ans[i]!=0);
		if(flag)cout<<ans[i];	
	}
	cout<<'\n';
}
signed main(){
#ifdef pig
	freopen("pig.in","r",stdin);
	freopen("pig.out","w",stdout);
#endif
	cin>>t;
	while(t--){
		scanf("%lld%lld",&x,&k);
		/*if(n<k){
		  cout<<-1<<'\n';
		  continue;
		  }*/
		fr(i,1,50){
			p[i]=x%10;
			x/=10;
		}
		fr(i,1,50)ans[i]=0;
		int pos=0;
		/*fr(i,k+1,19)if(p[i]!=9){
			pos=i-1;break;
		}
		fr(i,1,k)ans+=T[pos-i]*(9-p[pos-i+1]);
		ans+=T[pos-k];*/
		fr(i,1,20)if(p[i]&&p[i+k]!=9){
			fr(j,i,i+k-1)ans[j]+=9-p[j];
			ans[i]++;
			out();
			goto End;
		}
		cout<<-1<<'\n';
		End:;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3656kb

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: 3740kb

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
99999999999999999900000000000000000
-1

result:

wrong answer 1st lines differ - expected: '100000', found: '-1'