10得2000次方
2025-09-20 16:25:47
发布于:北京
78阅读
0回复
0点赞
数据范围为10的2000次方,有人能用高精度写出这道题吗?在线等!
全部评论 6
家人们,别烧脑了,AI都做不出来
#include <iostream> #include <vector> #include <algorithm> using namespace std; // 高精度乘法:将高精度数a乘以整数b vector<int> multiply(vector<int> a, int b) { vector<int> result; int carry = 0; for (int i = 0; i < a.size() || carry != 0; i++) { int digit = (i < a.size() ? a[i] : 0) * b + carry; carry = digit / 10; result.push_back(digit % 10); } // 去除前导零 while (result.size() > 1 && result.back() == 0) { result.pop_back(); } return result; } // 高精度数转字符串 string to_string(vector<int> num) { string result; for (int digit : num) { result += to_string(digit); } return result; } int main() { int N; cin >> N; if (N == 0) { cout << 1 << endl; return 0; } vector<int> power = {1}; // 初始值为2^0=1 for (int i = 0; i < N; i++) { power = multiply(power, 2); // 每次乘以2 } cout << to_string(power) << endl; return 0; }
昨天 来自 北京
1出自国货之光Deepseek之手
昨天 来自 北京
0shazi,
#include<bits/stdc++.h> using namespace std; string a; int main(){ int n; cin>>n; cout<<(1ll<<n); }
gaoding
15小时前 来自 浙江
0
Python大法
1周前 来自 广东
1我不会python啊!
5天前 来自 北京
0
print(2 ** int(input()))
秒了昨天 来自 上海
0#include<bits/stdc++.h> using namespace std; string a; int main(){ int n; cin>>n; cout<<(1ll<<n); }
2天前 来自 浙江
0#include<bits/stdc++.h> using namespace std; string a; int main(){ int n; cin>>n; cout<<(1ll<<n); }
5天前 来自 广东
0试了,不行
2天前 来自 北京
0谢谢建议
2天前 来自 北京
0??
2天前 来自 广东
0
我同学手算2的19次方
1周前 来自 福建
0那很棒了
5天前 来自 北京
0
有帮助,赞一个