20pts 求调,玄关

P1045 [NOIP2003 普及组] 麦森数

dengruijie3 @ 2024-09-29 11:09:58

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;
}

by dengruijie3 @ 2024-10-02 21:01:29

@rexmqy @3Luby3 @man_8_24 @AC_zzh2013 @lizhixun @AK_lwh_888 @Ak_hjc_using


by dengruijie3 @ 2024-10-02 21:02:09

@3Luby3 @AC_zzh2013 @lizhixun @AK_lwh_888 @Ak_hjc_using


by 3Luby3 @ 2024-10-02 21:09:53

@dengruijie3 em


by 3Luby3 @ 2024-10-02 21:12:01

@dengruijie3 把我@也没用,你在灌水去发


by Ak_hjc_using @ 2024-10-02 21:35:30

@dengruijie3 这么简单,自己想。


by AK_lwh_888 @ 2024-10-03 20:36:51

@dengruijie3 竟然手切黄题


by AK_lwh_888 @ 2024-10-03 20:37:48

@dengruijie3 你怎么又开个小号啊,都 [dengruijie3](/user/1482261)


by dengruijie3 @ 2024-10-03 21:42:24

@Ak_hjc_using 求调,调出来3个关注


by Ak_hjc_using @ 2024-10-04 08:15:26

@dengruijie3 自己看题解,看自己哪里错了,我又不是你的老师。


|