Submission #19300

#TimeUsernameProblemLanguageResultExecution timeMemory
19300aintaΣ (kriii4_P2)C++98
100 / 100
4 ms1084 KiB
#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 timeMemoryGrader output
Fetching results...