Submission #19338

# Submission time Handle Problem Language Result Execution time Memory
19338 2016-02-24T10:07:42 Z gs13068 Σ (kriii4_P2) C++
100 / 100
6 ms 1084 KB
#include <cstdio>

const int p = 1000000007;

int f(int x, int y)
{
	return y & 1 ? (long long)f(x, y ^ 1)*x%p : y ? f((long long)x*x%p, y >> 1) : 1;
}

int main()
{
	int n, a, b, r = 0;
	scanf("%d", &n);
	while (n--)
	{
		scanf("%d%d", &a, &b);
		r = (r + (long long)f(a, p - 2)*b) % p;
	}
	printf("%d", r);
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1084 KB Output is correct
2 Correct 5 ms 1084 KB Output is correct
3 Correct 6 ms 1084 KB Output is correct
4 Correct 0 ms 1084 KB Output is correct
5 Correct 0 ms 1084 KB Output is correct
6 Correct 0 ms 1084 KB Output is correct
7 Correct 0 ms 1084 KB Output is correct
8 Correct 0 ms 1084 KB Output is correct
9 Correct 0 ms 1084 KB Output is correct
10 Correct 0 ms 1084 KB Output is correct
11 Correct 6 ms 1084 KB Output is correct
12 Correct 0 ms 1084 KB Output is correct
13 Correct 0 ms 1084 KB Output is correct
14 Correct 0 ms 1084 KB Output is correct
15 Correct 0 ms 1084 KB Output is correct
16 Correct 0 ms 1084 KB Output is correct
17 Correct 0 ms 1084 KB Output is correct
18 Correct 0 ms 1084 KB Output is correct
19 Correct 4 ms 1084 KB Output is correct
20 Correct 5 ms 1084 KB Output is correct