QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#560244 | #6407. Classical A+B Problem | ucup-team4893# | WA | 0ms | 3588kb | C++14 | 1.7kb | 2024-09-12 14:32:58 | 2024-09-12 14:32:59 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
string n;
int digitsum(string n) {
if(n[0] != '0') return -1;
reverse(n.begin(), n.end());
n.pop_back();
int cnt = 0, sum = 0, q = 0;
for(char ch : n) {
if(q && sum == 1) sum += 10000000;
if(ch != '0') {
cnt++, sum += ch - 48;
if(cnt == 2 && !q) sum %= 100;
q = 1;
}
else q = 0;
if(cnt > 2) return -1;
}
return sum;
}
void work() {
cin >> n;
reverse(n.begin(), n.end());
n += '0';
int p = 0;
for(char &ch : n) {
ch -= 48;
ch = ch * 9 + p;
p = ch / 10;
ch %= 10;
ch += 48;
}
if(n.back() == '0') n.erase(n.size() - 1, 1);
//cout << n << '\n';
for(int i = 1; i <= 18; i++) {
n += '0';
int p = 1;
for(char &ch : n) {
ch -= 48;
ch = ch + p;
p = ch / 10;
ch %= 10;
ch += 48;
}
if(n.back() == '0') n.erase(n.size() - 1, 1);
if(i == 1) continue;
int ds = digitsum(n);
//cout << n << ' ' << i << ' ' << ds << endl;
if(ds % 100 == i) {
int i1 = 0, i2 = 0;
while(n[i1] == 48) i1++;
i2 = i1 + 1;
while(n[i2] == 48) i2++;
int flg = 0;
if(n[i1] - 48 == i) flg = 1, n[i1]--, i2 = i1;
for(int j = 0; j < i1; j++) cout << n[i1]; cout << ' ';
n[i1] = '1';
for(int j = 0; j < i2; j++) cout << n[i2]; cout << '\n';
}
else if(ds % 100 == i % 10 + 1 && ds > 100) {
//cout << n << '\n';
int i1 = 0;
while(n[i1] == 48) i1++;
for(int j = 0; j < i1; j++) cout << 9; cout << ' ';
i -= 9;
for(int j = 0; j < i1; j++) cout << i; cout << '\n';
}
else continue;
break;
}
}
signed main() {
ios::sync_with_stdio(false); cin.tie(0);
int _; cin >> _; while(_--) work();
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3588kb
input:
6 2 786 1332 89110 2333333 10000000000000000000000000001
output:
1 1 9 777 999 333 222 88888 111111 2222222 2 9999999999999999999999999999
result:
ok ok (6 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3588kb
input:
100 854 77777777781111111111111111110 44444450 11111111111111333 2310 5 333333333333333333333343332 888999 10 11113333 335 77779 88888888888888888888889111111111111111111110 55555555555555777777 72222222222222222222221 666 5777 1111555555 444444444544444444443 88888888888891111111111110 673332 97 77...
output:
77 777 3333333333333333333 77777777777777777777777777777 6 44444444 222 11111111111111111 88 2222 4 1 9999 333333333333333333333333333 111 888888 99 11 2222 11111111 2 333 2 77777 222222222222222222222 88888888888888888888888888888888888888888888 222222 55555555555555555555 5555555555555555555555 66...
result:
wrong answer x + y > n (test case 9)