QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#413745#8177. Sum is IntegerpemguimnWA 1ms5588kbC++23924b2024-05-18 00:35:492024-05-18 00:35:50

Judging History

This is the latest submission verdict.

  • [2024-05-18 00:35:50]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 5588kb
  • [2024-05-18 00:35:49]
  • Submitted

answer

#include <bits/stdc++.h>
#define ll long long
#define lint __int128
using namespace std;

const int N = 2e5 + 5;
int n;
ll p[N], q[N];

const ll mod1 = 1000000000000000000 + 3;
const ll mod2 = 1000000000000000000 + 4;

map<ll, ll> mp;

ll binpow(ll x, ll y, ll mod){
    ll res = 1;
    for(; y; y >>= 1){
        if(y & 1) res = ((lint) res * x) % mod;
        x = ((lint) x * x) % mod;
    }
    return res;
}
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    mp[0]++;

    ll s1 = 0, s2 = 0, ans = 0;
    for(int i = 1; i <= n; i++) {
        cin >> p[i] >> q[i];
        p[i] %= q[i];
        s1 = (s1 + ((lint) p[i] * binpow(q[i], mod1 - 2, mod1)) % mod1) % mod1;
        s2 = (s2 + ((lint) p[i] * binpow(q[i], mod2 - 2, mod2)) % mod2) % mod2;
        ans += mp[s1 - s2];
        mp[s1 - s2]++;
    }
    cout << ans << "\n";

    return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5588kb

input:

4
1 6
1 3
1 2
1 2

output:

0

result:

wrong answer 1st words differ - expected: '2', found: '0'