自测和测试用例没问题,但全是wa
查看原帖
自测和测试用例没问题,但全是wa
1127424
damuzhi楼主2023/11/3 21:17
//新
#include <bits/stdc++.h>

using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    int c[min(a,b)];
    int d[min(a,b)];
    for(int i = 0; i < min(a,b); i++){
        c[i] = -10000000;
        d[i] = -10000000;
    }
    int g = 0;
    for(int i = 1; i <= min(a,b); i++){
        if(a%i == 0 && b % i == 0){
            c[i-1] = i;
            // cout << 's';
            for(int j = 2 ; j < i; j++){
                if(i % j == 0){
                    break;
                }
                else if(j == i - 1){
                    d[i] = i;
                    g++;
                }
            }
        }
    }
    sort(c,c+min(a,b), greater<int>());
    int da = c[0];
    // for(int i = 0; i < min(a,b); i++){
    //     cout << c[i];
    // }
    sort(d,d+min(a,b), greater<int>());
    int zx = 1;
    for(int i = 0; i < g; i++){
        zx *= d[i];
    }
    zx *= a/zx * b/zx;
    cout << c[0] << ' ' << zx;
    return 0;
}
2023/11/3 21:17
加载中...