AC求助!
查看原帖
AC求助!
933808
Earth2023楼主2024/12/29 14:08

我的程序好像是正确(错误)的,过不了样例#1,但是样例#2与测试数据AC,求助!

#include <iostream>
using namespace std;
int main() {
    long long n, i, p = 1, t, all;
    cin >> n >> i;
    t = n;
    if (n == 1) {
        cout << 1;
        return 0;
    }
    while (t > 0) {
        t = n;
        all = p * n + i;
        while (t > 0) {
            t--;
            if (all % (n - 1) != 0) break;
            all = all / (n - 1) * n + i;
        }
        p++;
    }
    cout << all;
    return 0;
}
2024/12/29 14:08
加载中...