QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#583857 | #6300. Best Carry Player 2 | rxzfn639 | WA | 0ms | 3560kb | C++23 | 664b | 2024-09-22 23:10:29 | 2024-09-22 23:10:33 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const i64 P = 998244353;
i64 w[19];
void solve() {
i64 x, k;
cin >> x >> k;
for (int i = k; i < 19; i++) {
if (x / w[i] % 10 != 9 && (k == 0 || x % w[i - k + 1] != 0)) {
i64 ans = x % w[i - k] + (x / w[i] + 1) * w[i] - x;
cout << ans << '\n';
return;
}
}
cout << -1 << '\n';
return;
}
int main() {
w[0] = 1;
for (int i = 1; i < 19; i++) w[i] = w[i - 1] * 10;
// ios::sync_with_stdio(0); cin.tie(0), cout.tie(0);
int t = 1;
cin >> t;
while(t--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3552kb
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: 3560kb
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 -1 1000000000000000000
result:
wrong answer 11th lines differ - expected: '10000000001', found: '10000000000'