QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#478313#4395. ShuanQhorzward#WA 6ms3636kbC++171.2kb2024-07-14 20:26:412024-07-14 20:26:41

Judging History

This is the latest submission verdict.

  • [2024-07-14 20:26:41]
  • Judged
  • Verdict: WA
  • Time: 6ms
  • Memory: 3636kb
  • [2024-07-14 20:26:41]
  • Submitted

answer

#include <bits/stdc++.h>
#define int long long
#define fastio ios::sync_with_stdio(0), cin.tie(0)

using namespace std;

void solve()
{
    int p, q, e;
    cin >> p >> q >> e;
    int last = p * q - 1;
    // 枚舉m的質因數
    for(int i = 2; i * i <= last; i++) {
        if(last % i == 0){
            if(i > p && i > q && i > e && p * q % i == 1) {
                int raw_data = e * q % i;
                if(e == raw_data * p % i) {
                    cout << raw_data << '\n';
                    return;
                }
            }
            while(last % i == 0) last /= i;
        }
    }
    // 若還有最後一個質因數沒有枚舉到
    if(last != 1) {
        if(last > p && last > q && last > e && p * q % last == 1) {
            int raw_data = e * q % last;
            if(e == raw_data * p % last) {
                cout << raw_data << '\n';
                return;
            }
        }
    }
    cout << "-1\n";
    return;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 6ms
memory: 3636kb

input:

20
5 5 5
6 6 6
882719 680291 233333
989939 479970 53262
938708 679630 425532
984309 264462 254423
669395 343691 43951
574439 394839 546371
599167 899816 782539
756919 648539 507916
925966 1940263 1449550
1733740 811755 1715551
1320129 47186 477900
483330 1684637 108798
1283410 1345854 110616
1817138...

output:

-1
1
38432
698984
592545
974193
758594
258204965
165001059553
-1
57287706
1458297974
-1
5389551
1121735046
1081519
709978395
1606865
14874189
40086026015

result:

wrong answer 1st lines differ - expected: 'shuanQ', found: '-1'