Submission #15796

# Submission time Handle Problem Language Result Execution time Memory
15796 2015-07-29T10:41:03 Z didw 맛있는 과자 (kriii3_A) C++
Compilation error
0 ms 0 KB
#include <iostream>
#include <cmath>

using namespace std;

double rs, rb;

double solve(double S0, int n, int k) {
    if (n == 0)
        return log(S0);
    // k가 전체 과자 개수보다 크다면 작은 과자조각으로 반환
    if (k > (1<<n)) {
        return solve(S0*rs, n-1, k/2);
    }
    // 아니면 큰 조각으로 반환
    return solve(S0*rb, n-1, k);
}

int main() {
    int a, b, n, k;
    cin >> a >> b >> n >> k;
    if (a > b) swap(a, b);
    rs = (double)a*a / (double)(a*a + b*b);
    rb = (double)b*b / (double)(a*a + b*b);
    double S0 = a*b / 2.0;
    printf("%.10f\n", solve(S0, n, k));
}

Compilation message

A.cpp: In function ‘int main()’:
A.cpp:26:38: error: ‘printf’ was not declared in this scope
     printf("%.10f\n", solve(S0, n, k));
                                      ^