20pits,超时,我能理解,但是为什么会WA @-@
查看原帖
20pits,超时,我能理解,但是为什么会WA @-@
1269755
qyzzyqlqj楼主2025/7/19 17:11
如题
#include <bits/stdc++.h>
#define ull  unsigned long long
#define ll  long long
using namespace std;

int m[10020],n[10020],q[10020];


string h_time(string x, string y) {
    if (x == "0" || y == "0") return "0";
    
    string s = "";
    memset(q, 0, sizeof(q));
    int lenm = x.size(), lenn = y.size(), lenq = lenm + lenn + 1;
    for (int i = 0; i < lenm; i++) m[lenm - i] = x[i] - '0';
    for (int i = 0; i < lenn; i++) n[lenn - i] = y[i] - '0';
    for (int i = 1; i <= lenm; i++) {
        for (int j = 1; j <= lenn; j++) {
            q[i + j - 1] += m[i] * n[j];
            if (q[i + j - 1] >= 10) {
                q[i + j] += q[i + j - 1] / 10;
                q[i + j - 1] %= 10;
            }
        }
    }
    
    while (lenq > 1 && q[lenq] == 0) lenq--;
    for (int i = lenq; i > 0; i--) s += to_string(q[i]);
    return s;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a;
    cin>>a;
    string s="1";
    int b=a/30;
    string c=to_string(1<<30);
    
    for(int _=0;_<b;_++){
        s = h_time(c,s);
    }
    s=h_time(s,to_string(1<<(a%30)));
    
    
    s[s.size()-1]-=1;
    
    if(s.size()>=500){
        cout<<s.size()<<endl;
        string ss=s.substr(s.size()-500,500);
        for(int i=0;i<10;i++){
            for(int j=0;j<50;j++){
                cout<<ss[i*10+j];
            }
            cout<<endl;
        }
    }
    else{
        string ss="";
        cout<<s.size()<<endl;
        string leadingZeros(500 - s.size(), '0');
        s = leadingZeros + s;
        ss+=s;
        for (int i = 0; i < 10; i++) {
        cout << s.substr(i * 50, 50) << endl;
    }
        
        
    }
    
    return 0;
}
2025/7/19 17:11
加载中...