# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
18998 |
2016-02-17T02:51:19 Z |
kriii |
제비 (kriii4_W) |
C++14 |
|
21 ms |
9052 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);
}
long long D[1010][1010];
int main()
{
int T; scanf ("%d",&T); while (T--){
long long r,g,b,k;
scanf ("%lld %lld %lld %lld",&r,&g,&b,&k);
static int first = 0;
if (!first){
first = 1;
for (int j=1;j<=1000;j++){
D[0][j] = j * (1 + g * inv(b) % mod) % mod;
}
for (int i=1;i<=1000;i++){
long long v = inv(i+b);
for (int j=1;j<=1000;j++){
long long s = (i * D[i-1][j] + b * D[i][j-1] + i + g + b) % mod;
D[i][j] = s * v % mod;
}
}
}
printf ("%lld\n",D[r][k]);
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
9052 KB |
Output is correct |
2 |
Correct |
17 ms |
9052 KB |
Output is correct |
3 |
Correct |
12 ms |
9052 KB |
Output is correct |
4 |
Correct |
17 ms |
9052 KB |
Output is correct |
5 |
Correct |
21 ms |
9052 KB |
Output is correct |
6 |
Correct |
21 ms |
9052 KB |
Output is correct |
7 |
Correct |
17 ms |
9052 KB |
Output is correct |
8 |
Correct |
21 ms |
9052 KB |
Output is correct |
9 |
Correct |
21 ms |
9052 KB |
Output is correct |
10 |
Correct |
17 ms |
9052 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
20 ms |
9048 KB |
Program hung waiting for input |
2 |
Halted |
0 ms |
0 KB |
- |