hiho week 189 register

Ended

Participants:100

Verdict:Accepted
Score:100 / 100
Submitted:2018-02-16 01:25:54

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    double C[11], B[11];
    int N, K;
    cin >> N >> K;
    for (int i = 0; i < K; i++)
        cin >> C[i];
    for (int i = 0; i < K; i++)
        cin >> B[i];
        
    for (int i = 0; i < N; i++) {
        int choice = 0;
        double temp = log(1 + 1 / C[0]) / B[0];
        for (int j = 1; j < K; j++) {
            if (temp < (log(1 + 1 / C[j]) / B[j])) {
                temp = log(1 + 1 / C[j]) / B[j];
                choice = j;
            }
        }
        C[choice]++;
    }
    
    double P = 1;
    for (int i = 0; i < K; i++)
        P *= pow(C[i], 1 / B[i]);
        
    printf("%.3lf\n", P);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX