Submission #19485

# Submission time Handle Problem Language Result Execution time Memory
19485 2016-02-24T14:05:44 Z zych1751 Σ (kriii4_P2) C++
100 / 100
7 ms 1084 KB
#include<cstdio>

const int INF = 1e9+7;

long long mod(long long a) // a^(x-2)
{
	int mul = 1e9+5;
	long long result = 1;
	a %= INF;

	while(mul)
	{
		if(mul & 1)
			result = (result * a) % INF;
		a = (a*a) % INF;
		mul /= 2;
	}
	return result;
}

int main()
{
	int m;
	long long n, s;
	long long result = 0;

	scanf("%d", &m);
	for(int i = 0; i < m; i++)
	{
		scanf("%lld %lld", &n, &s);
		result += s * mod(n);
		result %= INF;
	}
	printf("%lld", result);
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1084 KB Output is correct
2 Correct 0 ms 1084 KB Output is correct
3 Correct 0 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 5 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 7 ms 1084 KB Output is correct
13 Correct 6 ms 1084 KB Output is correct
14 Correct 6 ms 1084 KB Output is correct
15 Correct 0 ms 1084 KB Output is correct
16 Correct 6 ms 1084 KB Output is correct
17 Correct 7 ms 1084 KB Output is correct
18 Correct 5 ms 1084 KB Output is correct
19 Correct 0 ms 1084 KB Output is correct
20 Correct 5 ms 1084 KB Output is correct