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:58:35
2017-05-27 12:16:52
2017-05-27 12:10:54
Task:Epic set
Sender:KnowYourArchitecture
Submission time:2017-05-27 15:58:35
Status:READY
Result:TIME LIMIT EXCEEDED

Show test data

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:24:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (first == a)
                      ^

Code

#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long int ull;

const ull N = 5000000;

ull counts[100];

inline double frac(double a) {
    return a - floor(a);
}

int main() {
    ull a, b;
    cin >> a >> b;
    
    ull res = 0;
    
    double l2 = log(2)/log(b);
    for (ull i = 1; i <= N; i++) {
        int first = floor(pow(b, frac(i*l2)));
        if (first == a)
            res++;
    }
    
#define FOO(testb) \
    if (realb == testb) {\
    for (int i = 0; i < N; i++) { \
        if (cur*2 <= cur) cur /= testb; \
        cur *= 2; \
        int c = cur; \
        while (c >= testb) c /= testb; \
        counts[c]++; \
    }}
        
    /*FOO(1)
    FOO(2)
    FOO(3)
    FOO(4)
    FOO(5)
    FOO(6)
    FOO(7)
    FOO(8)
    FOO(9)
    FOO(10)*/
    
    
    //for (int i = 0; i < 10; i++)
    //    cout<<i<<": "<<counts[i]<<endl;
    cout << fixed << setprecision(15) << double(res)/N << endl;
    
    return 0;
}