Submission #19592

#TimeUsernameProblemLanguageResultExecution timeMemory
19592pjh0123Σ (kriii4_P2)C++98
100 / 100
7 ms1256 KiB
#include <stdio.h> #include <string.h> #include <vector> #include <queue> #include <stdlib.h> #include <algorithm> #include <cmath> #define INFL 90000000000000000 #define PI 3.141592653589793238462643383279502884 #define SQ(a) ((a)*(a)) #define pb push_back #define mod 1000000007 typedef long long ll; typedef long double ld; typedef double dd; typedef std::pair<int,int> pii; using namespace std; ll m,n[11111],s[11111],inv,at,bt,a,b; ll in(ll a){ a%=mod; ll ret=1; ll x=mod-2; while(x){ if(x%2){ ret=ret*a%mod; } a=a*a%mod; x/=2; } return ret; } int main(){ at=1; bt=1; scanf("%lld",&m); for(int i=0;i<m;i++){ scanf("%lld%lld",&n[i],&s[i]); at=at*n[i]%mod; } a = in(at); b=0; for(int i=0;i<m;i++){ inv=in(n[i]); b=(b+inv*at%mod*s[i]%mod)%mod; } printf("%lld",a*b%mod); }
#Verdict Execution timeMemoryGrader output
Fetching results...