# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
19287 |
2016-02-24T06:03:37 Z |
kaTkaHr |
로봇 (kriii4_F) |
C++14 |
|
0 ms |
1092 KB |
#include <stdio.h>
#include<vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
const int MX = 1005, MM = 1000000007;
template<typename T>
T pw(T A, ll B){
T R = 1;
while(B){
if( B&1 ) R = R * A;
A = A * A; B /= 2;
}
return R;
}
ll rv(ll A){
ll R = 1, B = MM-2;
while(B){
if( B&1 ) R = R * A % MM;
A = A * A % MM; B /= 2;
}
return R;
}
//*
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; }
};// */
/*
struct frac{
ll A;
frac(ll A):A((A%MM+MM)%MM){}
frac(ll a, ll b){
a = (a%MM+MM)%MM;
b = (b%MM+MM)%MM;
A = rv(b) * a % MM;
}
frac(){A = 0;}
frac operator+ (const frac &l)const{
return l.A + A >= MM? l.A + A - MM: l.A + A;
}
frac operator*(const frac &l)const{
return l.A * A % MM;
}
frac operator/(const frac &l)const{
return A * rv(l.A) % MM;
}
frac operator- (const frac &l)const{
return A >= l.A? A-l.A: A-l.A + MM;
}
ll v(){ return A; }
};// */
struct Complex{
frac R, I;
Complex(frac R, frac I):R(R), I(I){}
Complex(frac R):R(R), I(0){}
Complex(ll R):R(R), I(0){}
frac norm()const{ return R*R + I*I; }
Complex operator+(const Complex &l)const{
return Complex(R+l.R, I+l.I);
}
Complex operator-(const Complex &l)const{
return Complex(R-l.R, I-l.I);
}
Complex operator*(const Complex &l)const{
return Complex(R*l.R - I*l.I, R*l.I + I*l.R);
}
Complex operator/(const Complex &l)const{
return Complex(R, I) * Complex(l.R, frac(0, 1)-l.I) / l.norm();
}
Complex operator/(const frac &l)const{
return Complex(R/l, I/l);
}
void print(){ printf("(%lld/%lld , %lld/%lld)", R.A, R.B, I.A, I.B); }
};
int main()
{
int N, L, M, R, T;
scanf("%d%d%d%d", &N, &L, &M, &R); T = L + M + R;
Complex K = Complex(frac(M, T), frac(R, T) - frac(L, T)), mul = 1;
Complex ans = (K*N - K*K*N - K + pw(K, N+1)) / (Complex(1)-K) / (Complex(1)-K);
ans = ans * 2 + N;
printf("%lld\n", ans.R.v());
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1092 KB |
Output is correct |
2 |
Incorrect |
0 ms |
1092 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Halted |
0 ms |
0 KB |
- |