This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
ll d[50][50];
void init(int N){
d[0][0]=1;
for(int i=1;i<=N;i++)
for(int j=0;j<=i;j++)
if(j==0)d[i][j]=1;
else d[i][j]=d[i-1][j]+d[i-1][j-1];
}
void f(int A,int B,double a,double b,double c){
double t;
for(int i=0;i<A;i++){
t=a+a-c;
b=a+b-c;
c=a;
a=t;
}
for(int i=0;i<B;i++){
t=b+b-c;
a=a+b-c;
c=b;
b=t;
}
cout<<a+b-log(2);
}
int main(){
ios::sync_with_stdio(0);
cout<<fixed;
cout.precision(12);
ll a,b,N,K;
cin>>a>>b>>N>>K;
init(N);
if(a>b)swap(a,b);
for(int i=0;i<=N;i++){
if(K<=d[N][i]){
f(i,N-i,log(a),log(b),log(sqrt(a*a+b*b)));
break;
}
K-=d[N][i];
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |