QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#411817#4395. ShuanQmobbb#AC ✓6ms3672kbC++20973b2024-05-15 20:03:372024-05-15 20:03:37

Judging History

This is the latest submission verdict.

  • [2024-05-15 20:03:37]
  • Judged
  • Verdict: AC
  • Time: 6ms
  • Memory: 3672kb
  • [2024-05-15 20:03:37]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;

#define ll long long

void solve(){
    ll p,q,e;
    cin >> p >> q >> e;

    ll tot = p * q - 1;

    for (ll i = 2;1ll * i * i <= tot;i++)if (tot % i == 0){
        if (i > p && i > q && i > e && p * q % i == 1ll){
            ll r = e * q % i;
            if (e == r * p % i){
                cout << r << "\n";
                return;
            }
        }        
        while (tot % i == 0){
            tot /= i;
        }
    }

    if (tot != 1){
        ll i = tot;
        if (i > p && i > q && i > e && p * q % i == 1ll){
            ll r = e * q % i;
            if (e == r * p % i){
                cout << r << "\n";
                return;
            }
        }        
    }
    cout << "shuanQ\n";
}

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

    int t;
    cin >> t;

    while (t--){
        solve();
    }

    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 6ms
memory: 3672kb

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:

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

result:

ok 20 lines