QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#314210#8177. Sum is Integerucup-team2303#WA 39ms10188kbC++171.4kb2024-01-25 14:23:482024-01-25 14:23:49

Judging History

你现在查看的是最新测评结果

  • [2024-01-25 14:23:49]
  • 评测
  • 测评结果:WA
  • 用时:39ms
  • 内存:10188kb
  • [2024-01-25 14:23:48]
  • 提交

answer

// #pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;

#define PB emplace_back
#define int long long
#define ll long long
#define vi vector<int>
#define siz(a) ((int) ((a).size()))
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
void print(vi n) { rep(i, 0, siz(n) - 1) cerr << n[i] << " \n"[i == siz(n) - 1]; }

const int N = 2e5, mod = 1e9 + 7;
int a, s[N + 5], inv[N + 5];
long double t[N + 5];
map<int, int> mp;

signed main() {
	// freopen(".in", "r", stdin);
	// freopen(".out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int tmp = 1;
	rep(i, 1, N) (tmp *= i) %= mod;
	inv[0] = inv[1] = 1;
	rep(i, 2, N) inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	rep(i, 1, N) (inv[i] *= tmp) %= mod;
	cin >> a;
	mp[0] = 1;
	int ans = 0, x, y;
	rep(i, 1, a) {
		cin >> x >> y;
		t[i] = t[i - 1] + 1.0 * x / y;
		s[i] = (x * inv[y] + s[i - 1]) % mod;

		x = t[i];

		// cout << (s[i] - x * tmp % mod + mod) % mod << endl;
		rep(j, x - 5, x + 5) if(mp.count((s[i] - j * tmp % mod + mod) % mod))
		ans += mp[(s[i] - j * tmp % mod + mod) % mod];
		++mp[(s[i] - x *  tmp % mod + mod) % mod];
	}
	cout << ans;
	return cerr << endl << 1.0 * clock() / CLOCKS_PER_SEC << endl, 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 7964kb

input:

4
1 6
1 3
1 2
1 2

output:

2

result:

ok "2"

Test #2:

score: 0
Accepted
time: 3ms
memory: 5984kb

input:

5
1 1
2 2
3 3
4 4
5 5

output:

15

result:

ok "15"

Test #3:

score: 0
Accepted
time: 0ms
memory: 7988kb

input:

2
1 99999
99999 100000

output:

0

result:

ok "0"

Test #4:

score: -100
Wrong Answer
time: 39ms
memory: 10188kb

input:

200000
82781 82781
86223 86223
16528 16528
84056 84056
94249 94249
54553 54553
25943 25943
10415 10415
52417 52417
46641 46641
70298 70298
84228 84228
55441 55441
49326 49326
11753 11753
89499 89499
58220 58220
71482 71482
32373 32373
7251 7251
78573 78573
74268 74268
46682 46682
20314 20314
85519 8...

output:

19799405516

result:

wrong answer 1st words differ - expected: '10603308211', found: '19799405516'