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 14:05:47
2017-05-27 12:58:05
Task:Epic set
Sender:Ace of Spades
Submission time:2017-05-27 14:05:47
Status:READY
Result:ACCEPTED

Show test data

Code

#include<bits/stdc++.h>

using namespace std;

int main(void) {
    cout << std::fixed << setprecision(12);
    int64_t a, b;
    cin >> a >> b;

    if (b == 4) {
	if (a <= 2) {
	    cout << 0.5 << '\n';
	} else {
	    cout << 0 << '\n';
	}
    } else if (b == 8) {
	if (a == 1 || a == 2 || a == 4) {
	    cout << 1.0/3.0 << '\n';
	} else {
	    cout << 0 << '\n';
	}
    } else {
	cout << (log(a+1) - log(a))/log(b) << '\n';
    }

    return 0;
}