WA on #34
查看原帖
WA on #34
637788
kimi0705楼主2023/6/24 20:07
#include <bits/stdc++.h>

#define int long long

using namespace std;

const int N = 1e6 + 10;

char ch[N];

int n, x, y, temp = 1;

int a[N], b[N];

signed main() {

    scanf("%s", ch + 1);

    cin >> x >> y;

    if(ch[1] == '0') {

        cout << "NO\n";

        return 0;

    }

    n = strlen(ch + 1);

    for (int i = 1; i <= n; i++) a[i] = (a[i - 1] * 10 + ch[i] - '0') % x;

    for (int i = n; i >= 1; i--) b[i] = (b[i + 1] + temp * (ch[i] - '0')) % y,temp = temp * 10 % y;

    for (int i = 1; i < n; i++)

        if (a[i] == 0 && b[i] == 0) {

            cout << "YES\n";

            for (int j = 1; j <= i; j++) cout << ch[j];

            cout << endl;

            for (int j = i + 1; j <= n; j++) cout << ch[j];

            return 0;

        }

    cout << "NO\n";

}
2023/6/24 20:07
加载中...