大佬求助,自己测试是对的,但发上去是0分,之前还有50分
查看原帖
大佬求助,自己测试是对的,但发上去是0分,之前还有50分
545866
lzq066楼主2021/8/11 23:31

我的代码如下

#include<bits/stdc++.h>
using namespace std;
int main( )
{
	int a[10005],b[10005]={0},c[10005],d[10005]={0},r[10005]={0},g[10005],h=2,o,n,j,ll=1,i,jwc,jwj,p=1,k,x,l,m,pp;
	cin>>n;
	r[1]=g[1]=1;
	for(i=1;i<=n;i++)
	{
		jwc=0;
		h=1;
		while(r[h])
		{
			a[h]=g[h];
			g[h]=r[h]=0;
			h++;
		}
		if(i/10)
		x=2;
		else
		x=1;
		m=i;
		l=1;
		while(m)
		{
			c[l]=m%10;
			l++;
			m=m/10;
		}
		for(j=1;j<=x;j++)
		{
			for(pp=1;pp<=h-1;pp++)
			{
				if(c[j]*a[pp]+jwc+g[j+pp-1]>=10)
				{
					o=g[j+pp-1];
					g[j+pp-1]=(c[j]*a[pp]+jwc+g[j+pp-1])%10;
					jwc=(c[j]*a[pp]+jwc+o)/10;
					r[j+pp-1]=1;
				}
				else
				{
					g[j+pp-1]=c[j]*a[pp]+jwc+g[j+pp-1];
					jwc=0;
					r[j+pp-1]=1;
				}
			}
		}
		if(jwc)
		{
			g[h]=jwc;
			r[h]=1;
			h++;
		}
		while(g[h])
		{
			r[h]=1;
			h++;
		}
		while(r[h])
		jwj=0;
		for(j=1;j<=h-1;j++)
		{
			if(b[j]+g[j]+jwj>9)
			{
				d[j]=b[j]+g[j]-10+jwj;
				jwj=1;
			}
			else
			{
				d[j]=b[j]+g[j]+jwj;
				jwj=0;
			}
		}
		if(jwj)
		{
			d[h]=jwj;
			h++;
		}
		for(j=1;j<=h-1;j++)
		b[j]=d[j];
	}
	for(i=h-1;i>=1;i--)
	cout<<d[i];
}
2021/8/11 23:31
加载中...