QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#583853#5149. Best Carry Playerrxzfn639WA 0ms3684kbC++23664b2024-09-22 23:08:472024-09-22 23:08:48

Judging History

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

  • [2024-09-22 23:08:48]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3684kb
  • [2024-09-22 23:08:47]
  • 提交

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;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3684kb

input:

2
3
9 99 999
1
12345

output:

999999997
-1

result:

wrong answer 1st numbers differ - expected: '5', found: '999999997'