QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#191200#6407. Classical A+B Problemsmosp#WA 0ms3600kbC++231.4kb2023-09-29 20:20:572023-09-29 20:20:58

Judging History

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

  • [2023-09-29 20:20:58]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3600kb
  • [2023-09-29 20:20:57]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

  int tt;
  cin >> tt;
  while(tt--) {
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    int n = s.size();
    string ansa, ansb;
    for (int x = 1; x <= 9; x++) {
      for (int y = 1; y <= 9; y++) {
        int carry = 0;
        bool end_b = false, end_a = false, ok = true;
        string a, b;
        for (int i =0; i < n; i++) {
          int d = s[i] - '0';
          if (!end_b && (x + y + carry)%10 == d) {
            carry = (x + y + carry)/10;
            a.push_back('0'+x);
            b.push_back('0'+y);
          } else if (!end_a && (x + carry)%10 == d) {
            end_b = true;
            carry = (x+carry)/10;
            a.push_back('0'+x);
          } else if (carry == d) {
            end_a = end_b = true;
            carry = 0;
          } else {
            ok = false;
            break;
          }
        }
        if (ok) {
          ansa = a;
          ansb = b;
          goto end;
        }
      }
    }
    assert(false);
  end:;
    cout << ansa << " " << ansb << '\n';
  }
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3600kb

input:

6
2
786
1332
89110
2333333
10000000000000000000000000001

output:

1 1
777 9
333 999
88888 222
2222222 111111
9999999999999999999999999999 2

result:

ok ok (6 test cases)

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3596kb

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:

777 77
77777777777777777777777777777 3333333333333333333
44444444 6
11111111111111111 222
2222 88
1 4
333333333333333333333333333 9999
888888 111
11 99
11111111 2222
333 2
77777 2
88888888888888888888888888888888888888888888 222222222222222222222
55555555555555555555 222222
66666666666666666666666 5...

result:

wrong answer x + y > n (test case 9)