Submission #19243

# Submission time Handle Problem Language Result Execution time Memory
19243 2016-02-22T12:13:50 Z kaTkaHr Σ (kriii4_P2) C++14
0 / 100
732 ms 1160 KB
#include <stdio.h>
#include <algorithm>
#include <map>

using namespace std;

typedef long long ll;

const int MX = 10005, MM = 1000000007;

ll pw(ll A, ll B){
	ll R = 1;
	while(B){
		if( B & 1 ) R = R * A % MM;
		A = A * A % MM; B /= 2;
	}
	return R;
}

ll rv(ll A){ return pw(A, MM-2); }

int N[MX], S[MX];

int main()
{
	int M;
	scanf("%d", &M);
	for(int i = 1; i <= M; i++){
		scanf("%d%d", N+i, S+i);
	}
	ll ans = 0;
	for(int i = 1; i <= M; i++){
		ll t = 1;
		for(int j = 1; j <= M; j++){
			if(i == j) t = t * S[i] % MM;
			else t = t * N[i] % MM;
		}
		ans = (ans + t) % MM;
	}
	for(int i = 1; i <= M; i++){
		ans = ans * rv(N[i]) % MM;
	}
	printf("%lld\n", ans);
}
# Verdict Execution time Memory Grader output
1 Incorrect 732 ms 1160 KB Output isn't correct
2 Halted 0 ms 0 KB -