# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
19004 |
2016-02-17T02:54:28 Z |
kriii |
로봇 (kriii4_F) |
C++14 |
|
0 ms |
1088 KB |
#include <stdio.h>
const long long mod = 1000000007;
long long pow(long long a, long long p)
{
a %= mod;
p = (p % (mod - 1) + mod - 1) % (mod - 1);
long long r = 1;
while (p){
if (p & 1) r = r * a % mod;
a = a * a % mod;
p /= 2;
}
return r;
}
struct complex{
complex(){
x = y = 0;
}
complex(long long x_, long long y_){
x = (x_ % mod + mod) % mod;
y = (y_ % mod + mod) % mod;
}
long long x,y;
complex operator *(complex t){
return complex(x*t.x-y*t.y,x*t.y+y*t.x);
}
complex operator *(long long a){
return complex(x*a,y*a);
}
complex operator +(complex t){
return complex(x+t.x,y+t.y);
}
complex operator -(complex t){
return complex(x-t.x,y-t.y);
}
};
complex sum(complex u, long long n)
{
complex v(1,0),w,p,q; long long z=1,r=n;
while (n){
if (n & 1){
q = (q + p * z) * u + w;
p = p * u + v;
}
w = (w + v * z) * u + w;
v = v * u + v;
u = u * u;
n /= 2;
z *= 2;
}
return p * r - q;
}
int main()
{
long long n,l,m,r;
scanf ("%lld %lld %lld %lld",&n,&l,&m,&r);
long long inv = pow(l+m+r,-1);
complex u(m,l-r),v(m,r-l);
u = u * inv;
v = v * inv;
complex ans = sum(u,n) + sum(v,n) - complex(n,0);
printf ("%lld\n",ans.x);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1088 KB |
Output is correct |
2 |
Correct |
0 ms |
1088 KB |
Output is correct |
3 |
Correct |
0 ms |
1088 KB |
Output is correct |
4 |
Correct |
0 ms |
1088 KB |
Output is correct |
5 |
Correct |
0 ms |
1088 KB |
Output is correct |
6 |
Correct |
0 ms |
1088 KB |
Output is correct |
7 |
Correct |
0 ms |
1088 KB |
Output is correct |
8 |
Correct |
0 ms |
1088 KB |
Output is correct |
9 |
Correct |
0 ms |
1088 KB |
Output is correct |
10 |
Correct |
0 ms |
1088 KB |
Output is correct |
11 |
Correct |
0 ms |
1088 KB |
Output is correct |
12 |
Correct |
0 ms |
1088 KB |
Output is correct |
13 |
Correct |
0 ms |
1088 KB |
Output is correct |
14 |
Correct |
0 ms |
1088 KB |
Output is correct |
15 |
Correct |
0 ms |
1088 KB |
Output is correct |
16 |
Correct |
0 ms |
1088 KB |
Output is correct |
17 |
Correct |
0 ms |
1088 KB |
Output is correct |
18 |
Correct |
0 ms |
1088 KB |
Output is correct |
19 |
Correct |
0 ms |
1088 KB |
Output is correct |
20 |
Correct |
0 ms |
1088 KB |
Output is correct |
21 |
Correct |
0 ms |
1088 KB |
Output is correct |
22 |
Correct |
0 ms |
1088 KB |
Output is correct |
23 |
Correct |
0 ms |
1088 KB |
Output is correct |
24 |
Correct |
0 ms |
1088 KB |
Output is correct |
25 |
Correct |
0 ms |
1088 KB |
Output is correct |
26 |
Correct |
0 ms |
1088 KB |
Output is correct |
27 |
Correct |
0 ms |
1088 KB |
Output is correct |
28 |
Correct |
0 ms |
1088 KB |
Output is correct |
29 |
Correct |
0 ms |
1088 KB |
Output is correct |
30 |
Correct |
0 ms |
1088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1088 KB |
Output is correct |
2 |
Correct |
0 ms |
1088 KB |
Output is correct |
3 |
Correct |
0 ms |
1088 KB |
Output is correct |
4 |
Correct |
0 ms |
1088 KB |
Output is correct |
5 |
Correct |
0 ms |
1088 KB |
Output is correct |
6 |
Correct |
0 ms |
1088 KB |
Output is correct |
7 |
Correct |
0 ms |
1088 KB |
Output is correct |
8 |
Correct |
0 ms |
1088 KB |
Output is correct |
9 |
Correct |
0 ms |
1088 KB |
Output is correct |
10 |
Correct |
0 ms |
1088 KB |
Output is correct |
11 |
Correct |
0 ms |
1088 KB |
Output is correct |
12 |
Correct |
0 ms |
1088 KB |
Output is correct |
13 |
Correct |
0 ms |
1088 KB |
Output is correct |
14 |
Correct |
0 ms |
1088 KB |
Output is correct |
15 |
Correct |
0 ms |
1088 KB |
Output is correct |
16 |
Correct |
0 ms |
1088 KB |
Output is correct |
17 |
Correct |
0 ms |
1088 KB |
Output is correct |
18 |
Correct |
0 ms |
1088 KB |
Output is correct |
19 |
Correct |
0 ms |
1088 KB |
Output is correct |
20 |
Correct |
0 ms |
1088 KB |
Output is correct |
21 |
Correct |
0 ms |
1088 KB |
Output is correct |
22 |
Correct |
0 ms |
1088 KB |
Output is correct |
23 |
Correct |
0 ms |
1088 KB |
Output is correct |
24 |
Correct |
0 ms |
1088 KB |
Output is correct |
25 |
Correct |
0 ms |
1088 KB |
Output is correct |
26 |
Correct |
0 ms |
1088 KB |
Output is correct |
27 |
Correct |
0 ms |
1088 KB |
Output is correct |
28 |
Correct |
0 ms |
1088 KB |
Output is correct |
29 |
Correct |
0 ms |
1088 KB |
Output is correct |
30 |
Correct |
0 ms |
1088 KB |
Output is correct |