题解 | #如何计算一个很大的次幂这个方法我们已经有所了解#
对于爆int的数据直接输出 2.718。字符串比大小即可。
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
const string maxull = "1000000000";
string s;
int main(){
cin >> s;
if(s.size() < maxull.size() || (s.size() == maxull.size() && s <= maxull)){
unsigned long long x = 0;
for(int i = 0; i < s.size(); i++)
x = x * 10 + (s[i] - '0');
printf("%.03Lf", pow(1 + 1 / (long double)x, (long double) x));
}
else printf("2.718");
return 0;
}