Submission #15818

# Submission time Handle Problem Language Result Execution time Memory
15818 2015-07-30T07:18:19 Z didw 맛있는 과자 (kriii3_A) C++
Compilation error
0 ms 0 KB
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

double rs, rb;
long long cache[41][41];

long long coef(int n, int r) {
    if (r == 0 || n == r) return 1;
    long long& ret = cache[n][r];
    if (ret != -1) return ret;
    ret = coef(n-1, r-1) + coef(n, r-1);
    return ret;
}

int main() {
    long long a, b, n, k;
    cin >> a >> b >> n >> k;
    if (a > b) swap(a, b);
    rs = log((double)a*a / (double)(a*a + b*b));
    rb = log((double)b*b / (double)(a*a + b*b));
    double S0 = log(a*b / 2.0);
    int idx = 0;
    memset(cache, -1, sizeof(cache));
    while (k > coef(n, idx)) {
        k -= coef(n, idx);
        idx++;
    }
    for (int i = 0; i < idx; ++i)
        S0 += rs;
    for (int i = idx; i < n; ++i)
        S0 += rb;
    printf("%.12f\n", S0);
}

Compilation message

A.cpp: In function ‘int main()’:
A.cpp:26:36: error: ‘memset’ was not declared in this scope
     memset(cache, -1, sizeof(cache));
                                    ^