题目大意:
输入n、p,n代表一个数的指数,p代表结果,求这个数的底数。P可以达到10^101。
解题思路:
因为数字非常大,可以用long double,可以达到10^4932。但是注意输出,数太大默认的输出是科学计数法,WA,要改成普通输出。
cout << fixed << setprecision(0);
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;
}
}

本文介绍了一种解决大数指数底数求解的方法,使用longdouble类型处理高达10^101的数值,并通过调整输出格式避免科学计数法导致的问题。

466

被折叠的 条评论
为什么被折叠?



