Submission #18997

#TimeUsernameProblemLanguageResultExecution timeMemory
18997kriii제비 (kriii4_W)C++14
100 / 100
2 ms1084 KiB
#include <stdio.h> const long long mod = 1000000007; long long pow(long long a, long long p) { long long r = 1; while (p){ if (p & 1) r = r * a % mod; a = a * a % mod; p /= 2; } return r; } long long inv(long long a) { return pow(a,mod-2); } int main() { int T; scanf ("%d",&T); while (T--){ long long r,g,b,k; scanf ("%lld %lld %lld %lld",&r,&g,&b,&k); long long ans = (r + k + k * g % mod * inv(b)) % mod; ans = (ans + mod - r * pow(b*inv(b+1)%mod,k) % mod) % mod; printf ("%lld\n",ans); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...