# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
19592 | pjh0123 | Σ (kriii4_P2) | C++98 | 7 ms | 1256 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |