您的位置:首页 > 其它

uva - 113 - Power of Cryptography

2014-01-26 10:24 253 查看

题目大意:

输入n、p,n代表一个数的指数,p代表结果,求这个数的底数。P可以达到10^101。

解题思路:

因为数字非常大,可以用long double,可以达到10^4932。但是注意输出,数太大默认的输出是科学计数法,WA,要改成普通输出。

cout << fixed << setprecision(0);

AC代码:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm>
using namespace std;

int main()
{
#ifdef Local
	freopen("a.in", "r", stdin);
	freopen("a.out", "w", stdout);
#endif
	long double p = 0, n = 0;
	while (cin >> n >> p)
	{
		n = 1.0/n;
		cout << fixed << setprecision(0) << pow(p, n) << endl;
	}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: