QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#293773 | #6300. Best Carry Player 2 | SunlightZero | WA | 0ms | 3548kb | C++14 | 2.2kb | 2023-12-29 18:53:47 | 2023-12-29 18:53:48 |
Judging History
answer
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstring>
#include <deque>
using namespace std;
bool is_carry[55];
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
size_t t;
cin >> t;
for (size_t _ = 1; _ <= t; _++)
{
string x_str;
size_t k;
cin >> x_str >> k;
if (k == 0)
{
cout << "0\n";
continue;
}
size_t n_post_zero = 0;
bool post_end = false;
memset(is_carry, 0, sizeof(is_carry));
deque<unsigned> dq;
for (auto it = x_str.rbegin(); it != x_str.rend(); ++it)
{
char ch = *it;
if (!post_end)
{
if (ch == '0')
{
n_post_zero++;
}
else
{
post_end = true;
dq.push_back(ch - '0');
}
}
else
{
dq.push_back(ch - '0');
}
}
while (dq.size() <= 50)
{
dq.push_back(0);
}
int i = 0, j;
size_t cnt = 0;
for (j = 0; j < (int) dq.size(); j++)
{
cnt++;
if (cnt == k)
{
if (dq[j + 1] == 9)
{
do {
i++;
cnt--;
} while (dq[i] == 0);
}
else
{
break;
}
}
}
string ans = "";
bool is_post_zero = true;
for (int k = j; k >= i; k--)
{
if (is_post_zero && dq[k] == 9)
{
continue;
}
else
{
is_post_zero = false;
ans += '0' + (9u + (i == k) - dq[k]);
}
}
for (int k = i - 1; k >= 0; k--)
{
ans += '0';
}
while (n_post_zero--)
{
ans += '0';
}
cout << ans << '\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3548kb
input:
4 12345678 0 12345678 5 12345678 18 990099 5
output:
0 54322 999999999987654322 9910
result:
wrong answer 1st lines differ - expected: '1', found: '0'