답안 #15238

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
15238 2015-07-12T04:22:29 Z sujin 맛있는 과자 (kriii3_A) C++
33 / 33
0 ms 1196 KB
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <math.h>

long long combination(int n, int r){
	int p[40] = { 0 };
	for (int i = r + 1; i <= n; i++){
		int t = i;
		for (int j = 2; j <= t; j++){
			while (t % j == 0){
				t /= j;
				p[j]++;
			}
		}
	}
	for (int i = 1; i <= n - r; i++){
		int t = i;
		for (int j = 2; j <= t; j++){
			while (t % j == 0){
				t /= j;
				p[j]--;
			}
		}
	}
	long long x = 1;
	for (int i = 2; i < 40; i++)
		while (p[i]--)
			x *= i;
	return x;
}

int main(){
	int a, b, N;
	long long K;

	scanf("%d %d %d %lld", &a, &b, &N, &K);

	double A = double(a < b ? a : b);
	double B = double(a > b ? a : b);
	double C = hypot(A, B);

	long long p = 0;
	for (int i = 0; i < K; i++){
		p += combination(N, i);
		if (p >= K){
			double x = A * B / 2;
			for (int j = 0; j < N - i; j++)
				x *= B * B;
			for (int j = 0; j < i; j++)
				x *= A * A;
			for (int j = 0; j < N; j++)
				x /= C * C;
			printf("%.12lf", log(x));
			break;
		}
	}

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1196 KB Output is correct
2 Correct 0 ms 1196 KB Output is correct
3 Correct 0 ms 1196 KB Output is correct
4 Correct 0 ms 1196 KB Output is correct
5 Correct 0 ms 1196 KB Output is correct
6 Correct 0 ms 1196 KB Output is correct
7 Correct 0 ms 1196 KB Output is correct
8 Correct 0 ms 1196 KB Output is correct
9 Correct 0 ms 1196 KB Output is correct
10 Correct 0 ms 1196 KB Output is correct
11 Correct 0 ms 1196 KB Output is correct
12 Correct 0 ms 1196 KB Output is correct
13 Correct 0 ms 1196 KB Output is correct
14 Correct 0 ms 1196 KB Output is correct
15 Correct 0 ms 1196 KB Output is correct
16 Correct 0 ms 1196 KB Output is correct
17 Correct 0 ms 1196 KB Output is correct
18 Correct 0 ms 1196 KB Output is correct
19 Correct 0 ms 1196 KB Output is correct
20 Correct 0 ms 1196 KB Output is correct
21 Correct 0 ms 1196 KB Output is correct
22 Correct 0 ms 1196 KB Output is correct
23 Correct 0 ms 1196 KB Output is correct
24 Correct 0 ms 1196 KB Output is correct
25 Correct 0 ms 1196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1196 KB Output is correct
2 Correct 0 ms 1196 KB Output is correct
3 Correct 0 ms 1196 KB Output is correct
4 Correct 0 ms 1196 KB Output is correct
5 Correct 0 ms 1196 KB Output is correct
6 Correct 0 ms 1196 KB Output is correct
7 Correct 0 ms 1196 KB Output is correct
8 Correct 0 ms 1196 KB Output is correct
9 Correct 0 ms 1196 KB Output is correct
10 Correct 0 ms 1196 KB Output is correct
11 Correct 0 ms 1196 KB Output is correct
12 Correct 0 ms 1196 KB Output is correct
13 Correct 0 ms 1196 KB Output is correct
14 Correct 0 ms 1196 KB Output is correct
15 Correct 0 ms 1196 KB Output is correct
16 Correct 0 ms 1196 KB Output is correct
17 Correct 0 ms 1196 KB Output is correct
18 Correct 0 ms 1196 KB Output is correct
19 Correct 0 ms 1196 KB Output is correct
20 Correct 0 ms 1196 KB Output is correct
21 Correct 0 ms 1196 KB Output is correct
22 Correct 0 ms 1196 KB Output is correct
23 Correct 0 ms 1196 KB Output is correct
24 Correct 0 ms 1196 KB Output is correct
25 Correct 0 ms 1196 KB Output is correct