답안 #18997

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
18997 2016-02-17T02:50:58 Z kriii 제비 (kriii4_W) C++14
100 / 100
2 ms 1084 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1084 KB Output is correct
2 Correct 1 ms 1084 KB Output is correct
3 Correct 0 ms 1084 KB Output is correct
4 Correct 0 ms 1084 KB Output is correct
5 Correct 0 ms 1084 KB Output is correct
6 Correct 0 ms 1084 KB Output is correct
7 Correct 0 ms 1084 KB Output is correct
8 Correct 0 ms 1084 KB Output is correct
9 Correct 0 ms 1084 KB Output is correct
10 Correct 0 ms 1084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1084 KB Output is correct
2 Correct 1 ms 1084 KB Output is correct
3 Correct 0 ms 1084 KB Output is correct
4 Correct 2 ms 1084 KB Output is correct
5 Correct 1 ms 1084 KB Output is correct
6 Correct 0 ms 1084 KB Output is correct
7 Correct 1 ms 1084 KB Output is correct
8 Correct 1 ms 1084 KB Output is correct
9 Correct 2 ms 1084 KB Output is correct
10 Correct 1 ms 1084 KB Output is correct
11 Correct 0 ms 1084 KB Output is correct
12 Correct 0 ms 1084 KB Output is correct
13 Correct 0 ms 1084 KB Output is correct
14 Correct 0 ms 1084 KB Output is correct
15 Correct 1 ms 1084 KB Output is correct
16 Correct 2 ms 1084 KB Output is correct
17 Correct 1 ms 1084 KB Output is correct
18 Correct 0 ms 1084 KB Output is correct
19 Correct 0 ms 1084 KB Output is correct
20 Correct 0 ms 1084 KB Output is correct