QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#801499 | #8932. Bingo | Infinite_Loopers# | WA | 0ms | 3844kb | C++20 | 1.0kb | 2024-12-07 00:47:22 | 2024-12-07 00:47:27 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void add(string &a, ll x) {
auto it = a.rbegin();
while (x) {
x = x + (*it - '0');
*it = '0' + x%10;
x /= 10;
++it;
}
}
string solve1(string n, string m) {
if (n.find(m) != n.npos) return n;
string a = n;
ll p = 1;
for (int i = 0; i < ssize(m); i++) a.rbegin()[i] = m.rbegin()[i], p *= 10;
if (a < n) {
add(a, p);
}
string b = n;
for (int i = 0; i < ssize(m); i++) b.rbegin()[i+1] = m.rbegin()[i];
b.back() = '0';
if (n <= b && b < a) return b;
return a;
}
string solve2(string n, string m) {
ll lm = stoll(m);
ll r = 0;
for (char ch: n) {
r = (r * 10 + ch - '0') % lm;
}
add(n, (lm-r)%lm);
return n;
}
int main() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int n_tests;
cin >> n_tests;
for (int test = 0; test < n_tests; test++) {
string n, m;
cin >> n >> m;
n.insert(0, "00000000000");
add(n, 1);
//cerr << solve1(n, m) << " " << solve2(n, m) << "\n";
cout << min(solve1(n, m), solve2(n, m)) << "\n";
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3844kb
input:
6 7 3 12 3 9 10 249 51 1369 37 2 1
output:
000000000009 0000000000013 000000000010 00000000000251 000000000001370 000000000003
result:
wrong answer 1st lines differ - expected: '9', found: '000000000009'