UVaOJ 113 - Power of Cryptography

 


Description

给出 n 和 p。

求出 p 的 n 次方根。


Type

Maths - Misc


Analysis

虽然题目中的 p 值很大。

但我们仍然可以用 double 类型来解决。

但是不知是精度问题还是 WTF 问题。

利用 log() 来计算是不行的,只能用 pow() 来计算,同时结果要四舍五入。

话说 pow() 还真是万能啊。


Solution

// UVaOJ 113
// Power of Cryptography 
// by A Code Rabbit

#include <cstdio>
#include <cmath>

double n, p;

int main() {
    while (scanf("%lf%lf", &n, &p) != EOF) {
        printf("%d\n", (int)(pow(p, 1 / n) + 0.5));
    }

    return 0;
}

你可能感兴趣的:(UVaOJ 113 - Power of Cryptography)