错在哪里?!?!?!?!?!?!?!?!?

P1045 [NOIP2003 普及组] 麦森数

HereWeGoJC @ 2018-07-18 20:01:39

include<bits/stdc++.h>

using namespace std;

int main()

{

int num[40]={1},n;
cin>>n;
printf("%d\n",(int)(n*log10(2)+1));
int k=1;
int q=0;
for(int i=0;i<=n-1;i++)
{
    int carry=0;
    for(int j=0;j<=k-1;j++)
    {
        num[j]=num[j]*2+carry;
        carry=num[j]/10;
        num[j]=num[j]%10;
    }
    if(carry)
    {
        num[k++]=carry;
    }
}
num[0]--;
for (int a=500;a>=1;a--)
{
    q++;
    cout<<num[a];
    if (q==50)
    {
        cout<<endl;
        q=0;
    }
}

}


|