随机分求rp

P1001 A+B Problem

ECNUAT_LZX @ 2024-07-26 10:58:15

违规紫衫QAQ

#include <bits/stdc++.h>

#define int long long
using namespace std;

signed main() {
    srand(time(0));
    int a, b;
    cin >> a >> b;
    while (1) {
        int ans = rand() % (int) (2e9+1);
        if (ans == a + b) {
            cout << ans;
            return 0;
        }
    }
    return 0;
}

by Aixan @ 2024-07-30 10:03:34

建议rand()改成mt19937,以及本题还有负数也要考虑一下


上一页 |