Code Submission Evaluation System Login

CSES - HIIT Open 2017

HIIT Open 2017

Contest start:2017-05-27 11:00:00
Contest end:2017-05-27 16:00:00

Task list | Submit code | Submissions | Messages | Scoreboard


History
2017-05-27 15:27:52
Task:Epic set
Sender:Nää jäbät
Submission time:2017-05-27 15:27:52
Status:READY
Result:ACCEPTED

Show test data

Code

#include <bits/stdc++.h>

#define ll long long
#define ld double

using namespace std;

#define M 20000000

int am[10];

int main () {
    int a, k;
    cin>>a>>k;
    ld lg = log(2) / log(k);
    ld x = 1;
    int z = (int)lg;
    if (z) x /= k;
    for (int i = 1; i <= M; i++) {
        x *= 2;
        if ((int)(lg * i) != z) {
            z++;
            x /= k;
        }
        am[(int)x]++;
    }
    cout<<setprecision(10)<<(ld)am[a]/(ld)M<<endl;
}