QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#413743#8177. Sum is IntegerpemguimnWA 0ms3840kbC++23916b2024-05-18 00:32:532024-05-18 00:32:54

Judging History

This is the latest submission verdict.

  • [2024-05-18 00:32:54]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3840kb
  • [2024-05-18 00:32:53]
  • 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 = 2000000000000000002;
const ll mod2 = 2000000000000000003;

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;
}


詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3840kb

input:

4
1 6
1 3
1 2
1 2

output:

0

result:

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