优雅的暴力.用高精加做完了2的n次方
  • 板块灌水区
  • 楼主_CHEN09
  • 当前回复12
  • 已保存回复13
  • 发布时间2024/9/30 20:08
  • 上次更新2024/9/30 22:01:07
查看原帖
优雅的暴力.用高精加做完了2的n次方
971322
_CHEN09楼主2024/9/30 20:08

//https://www.luogu.com.cn/paste/fzd61p2t //用高精加做完了2的n次方,共41行``` #include <bits/stdc++.h> using namespace std; #define maxx 31 int a[maxx],c[maxx]; bool f(int z,int x[]) { for(int i=z;i>=0;i--){ if (x[i]) return 0; } return 1; } int main() { int n,len=maxx-1; a[maxx-1]=2; c[maxx-1]=2; cin>>n; while(--n) { int j=maxx-1; bool b=1; while(b){ c[j]+=a[j]; if (f(j-1,a)) b=0; c[j-1]+=c[j]/10; c[j]%=10; j--; } copy(begin(c),end(c),begin(a)); } int z=0; while((!a[z])) { z++; } for(int i=z;i<=len;i++){ cout<<a[i]; } return 0; }

2024/9/30 20:08
加载中...