20pts 求调,玄关
查看原帖
20pts 求调,玄关
1482261
dengruijie3楼主2024/9/29 11:09

rt

#include<bits/stdc++.h>
#define int long long
using namespace std;

int n;
string mul(string a, int b){
	int jw = 0, len = a.size();
	string c;
	for (int i = len - 1; i >= 0; i--){
		int t = (a[i] - '0') * b + jw;
		jw = t / 10;
		c = char(t % 10 + '0') + c;
	}
	if (jw) c = to_string(jw) + c;
	return c;
} 

string sub(string a, int b){
	int len = a.size();
	while(a.size() < len){
		a = '0' + a;
	}
	string c;
	for (int i = len - 1; i >= 0; i--){
		int t = a[i] - b - '0'; 
		if (t < 0){
			t += 10;
			a[i - 1] -= 1;
		}
		else{
			a[i] = char(t + '0');
			break;
		}
	}
	return a;
} 


signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	string s = "1";
	for (int i = 1; i <= n; i++){
		s = mul(s, 2);
	}
	s = sub(s, 1);
	cout << s.size() << '\n';
	while(s.size() < 500) s = '0' + s;
	s = ' ' + s;
	for (int i = 1; i <= 500; i++){
		cout << s[i];	
		if (i % 50 == 0){
			cout << '\n';
		}
	} 
	return 0;
}

2024/9/29 11:09
加载中...