# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
19270 |
2016-02-23T15:59:16 Z |
kaTkaHr |
제비 (kriii4_W) |
C++14 |
|
25 ms |
142176 KB |
#include <stdio.h>
#include<vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
const int MX = 3005, MM = 1000000007;
ll pw(ll A, ll B){
ll R = 1;
while(B){
if( B&1 ) R = R * A % MM;
A = A * A % MM; B /= 2;
}
return R;
}
ll rv(ll A){ return pw(A, MM-2); }
struct frac{
ll A, B;
frac(ll A):A(A), B(1){}
frac(ll a, ll b){
A = (a%MM+MM) % MM;
B = (b%MM+MM) % MM;
}
frac(){A = 0, B = 1;}
frac operator+ (const frac &l)const{
return frac((A * l.B + B * l.A) % MM, B * l.B % MM);
}
frac operator*(const frac &l)const{
return frac(A*l.A % MM, B*l.B % MM);
}
frac operator/(const frac &l)const{
return frac(A*l.B % MM, B*l.A % MM);
}
frac operator- (const frac &l)const{
return frac((A*l.B - B*l.A%MM + MM) % MM, B*l.B % MM);
}
ll v(){ return A * rv(B) % MM; }
};
frac pw(frac A, ll B){
frac R = 1;
while(B){
if( B&1 ) R = R * A;
A = A * A; B /= 2;
}
return R;
}
frac P[MX][MX];
int main()
{
int R, G, B, K, T;
int TT;
scanf("%d", &TT);
for(int tt = 1; tt <= TT; tt++){
scanf("%d%d%d%d", &R, &G, &B, &K);
frac ans = frac((ll)G * K, B) + (frac(1, 1) - pw(frac(B, 1+B), K)) * R + K;
printf("%lld\n", ans.v());
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
142176 KB |
Output is correct |
2 |
Correct |
9 ms |
142176 KB |
Output is correct |
3 |
Correct |
12 ms |
142176 KB |
Output is correct |
4 |
Correct |
16 ms |
142176 KB |
Output is correct |
5 |
Correct |
15 ms |
142176 KB |
Output is correct |
6 |
Correct |
15 ms |
142176 KB |
Output is correct |
7 |
Correct |
0 ms |
142176 KB |
Output is correct |
8 |
Correct |
14 ms |
142176 KB |
Output is correct |
9 |
Correct |
10 ms |
142176 KB |
Output is correct |
10 |
Correct |
25 ms |
142176 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
142176 KB |
Output is correct |
2 |
Correct |
19 ms |
142176 KB |
Output is correct |
3 |
Correct |
25 ms |
142176 KB |
Output is correct |
4 |
Correct |
21 ms |
142176 KB |
Output is correct |
5 |
Correct |
6 ms |
142176 KB |
Output is correct |
6 |
Correct |
9 ms |
142176 KB |
Output is correct |
7 |
Correct |
12 ms |
142176 KB |
Output is correct |
8 |
Correct |
17 ms |
142176 KB |
Output is correct |
9 |
Correct |
12 ms |
142176 KB |
Output is correct |
10 |
Correct |
14 ms |
142176 KB |
Output is correct |
11 |
Correct |
12 ms |
142176 KB |
Output is correct |
12 |
Correct |
8 ms |
142176 KB |
Output is correct |
13 |
Correct |
9 ms |
142176 KB |
Output is correct |
14 |
Correct |
16 ms |
142176 KB |
Output is correct |
15 |
Correct |
18 ms |
142176 KB |
Output is correct |
16 |
Correct |
11 ms |
142176 KB |
Output is correct |
17 |
Correct |
8 ms |
142176 KB |
Output is correct |
18 |
Correct |
7 ms |
142176 KB |
Output is correct |
19 |
Correct |
14 ms |
142176 KB |
Output is correct |
20 |
Correct |
14 ms |
142176 KB |
Output is correct |