QOJ.ac
QOJ
QOJ is currently under a maintenance. It might be unavailable in the following a few hours.
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#413745 | #8177. Sum is Integer | pemguimn | WA | 1ms | 5588kb | C++23 | 924b | 2024-05-18 00:35:49 | 2024-05-18 00:35:50 |
Judging History
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'