acgo题库
  • 首页
  • 题库
  • 学习
  • 天梯
  • 备赛

    竞赛

    • CSP-J/S
    • 蓝桥杯

    考级

    • GESP
    • CPA
    • 电子学会考级
  • 竞赛
  • 讨论
  • 团队
登录
注册
题目详情提交记录(0)
  • 快速幂

    #include<iostream> #include<vector> #include<cmath> using namespace std; vector<int> mul(vector<int> a,vector<int> b){ vector<int> res(a.size() + b.size() + 1,0); for(int i = 0;i < a.size();i++){ for(int j = 0;j < b.size();j++){ res[i + j] += a[i] * b[j]; } } int c = 0; for(int i = 0;i < res.size();i++){ int t = res[i] + c; res[i] = t % 10; c = t / 10; } while(c){ res.push_back(c % 10); c /= 10; } if(res.size() > 500) res.resize(500); while(res.size() < 100) res.push_back(0); return res; } vector<int> po(int p){ vector<int> a,b; a.push_back(1); b.push_back(2); while(p){ if(p % 2) a = mul(a,b); b = mul(b,b); p /= 2; } return a; } void out(vector<int> ans){ int c = 0; for(int i = 1;i <= 10;i++){ for(int j = c,cnt = 1;cnt <= 50;j++,cnt++){ cout << ans[ans.size() - 1 - j]; } c += 50; cout << endl; } } int main(){ int p; cin >> p; cout << floor(p * log10(2) + 1) << endl; vector<int> ans = po(p); if(ans.size() > 500) ans.resize(500); while(ans.size() < 500) ans.push_back(0); ans[0]--; for(int i = 0;ans[i] < 0;i++){ ans[i] += 10,ans[i + 1]--; } out(ans); return 0; }

    userId_undefined

    137****0822

    9月全勤卷王秩序白银时间刺客空间掌握者时空双修者快乐小狗
    1阅读
    0回复
    0点赞
暂无数据

提交答案之后,这里将显示提交结果~

首页