# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
19300 | ainta | Σ (kriii4_P2) | C++98 | 4 ms | 1084 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<algorithm>
using namespace std;
int n;
long long Mod = 1000000007, A, B, C, D, TA, TB;
long long Inv(long long a){
long long b = Mod - 2, r = 1;
while(b){
if(b%2)r=r*a%Mod;
a=a*a%Mod;b/=2;
}
return r;
}
int main(){
int i;
scanf("%d",&n);
A = 1, B = 0;
for(i=1;i<=n;i++){
scanf("%lld%lld",&C,&D);
TB = B*C+A*D;
TA = A*C;
TA%=Mod, TB%=Mod;
A = TA, B = TB;
}
printf("%lld\n",B*Inv(A)%Mod);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |