Submission #15846

# Submission time Handle Problem Language Result Execution time Memory
15846 2015-07-31T02:03:17 Z comet 맛있는 과자 (kriii3_A) C++
33 / 33
0 ms 1840 KB
#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
1 Correct 0 ms 1840 KB Output is correct
2 Correct 0 ms 1840 KB Output is correct
3 Correct 0 ms 1840 KB Output is correct
4 Correct 0 ms 1840 KB Output is correct
5 Correct 0 ms 1840 KB Output is correct
6 Correct 0 ms 1840 KB Output is correct
7 Correct 0 ms 1840 KB Output is correct
8 Correct 0 ms 1840 KB Output is correct
9 Correct 0 ms 1840 KB Output is correct
10 Correct 0 ms 1840 KB Output is correct
11 Correct 0 ms 1840 KB Output is correct
12 Correct 0 ms 1840 KB Output is correct
13 Correct 0 ms 1840 KB Output is correct
14 Correct 0 ms 1840 KB Output is correct
15 Correct 0 ms 1840 KB Output is correct
16 Correct 0 ms 1840 KB Output is correct
17 Correct 0 ms 1840 KB Output is correct
18 Correct 0 ms 1840 KB Output is correct
19 Correct 0 ms 1840 KB Output is correct
20 Correct 0 ms 1840 KB Output is correct
21 Correct 0 ms 1840 KB Output is correct
22 Correct 0 ms 1840 KB Output is correct
23 Correct 0 ms 1840 KB Output is correct
24 Correct 0 ms 1840 KB Output is correct
25 Correct 0 ms 1840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1840 KB Output is correct
2 Correct 0 ms 1840 KB Output is correct
3 Correct 0 ms 1840 KB Output is correct
4 Correct 0 ms 1840 KB Output is correct
5 Correct 0 ms 1840 KB Output is correct
6 Correct 0 ms 1840 KB Output is correct
7 Correct 0 ms 1840 KB Output is correct
8 Correct 0 ms 1840 KB Output is correct
9 Correct 0 ms 1840 KB Output is correct
10 Correct 0 ms 1840 KB Output is correct
11 Correct 0 ms 1840 KB Output is correct
12 Correct 0 ms 1840 KB Output is correct
13 Correct 0 ms 1840 KB Output is correct
14 Correct 0 ms 1840 KB Output is correct
15 Correct 0 ms 1840 KB Output is correct
16 Correct 0 ms 1840 KB Output is correct
17 Correct 0 ms 1840 KB Output is correct
18 Correct 0 ms 1840 KB Output is correct
19 Correct 0 ms 1840 KB Output is correct
20 Correct 0 ms 1840 KB Output is correct
21 Correct 0 ms 1840 KB Output is correct
22 Correct 0 ms 1840 KB Output is correct
23 Correct 0 ms 1840 KB Output is correct
24 Correct 0 ms 1840 KB Output is correct
25 Correct 0 ms 1840 KB Output is correct