各位大佬这道题本蒟蒻40分,哪位高手帮忙指正一下谢谢啦
查看原帖
各位大佬这道题本蒟蒻40分,哪位高手帮忙指正一下谢谢啦
579261
Xcy20101213楼主2023/2/25 12:02
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
long long b[N];
int main()
{
	long long n;
	cin>>n;
	long long a=2;
	long long  i=0;
	int d=n;
	while(n>=a)
	{
		n=n-a;
		b[i]=a;
		i++;
		a++;
	}
	long long j=0;
	while(n!=0&&n>=i)
	{
		b[j]++;
		if(j==i-1)
		{
			j=0;
		}
		j++;
		n--;
	}
	long long sum=1;
	if(n==0)
    	for(j=0;j<i;j++)
    	{
    		sum*=b[j];
	    	cout<<b[j]<<" ";
    	}
    else{
		for( j=i-n;j<i;j++)
		{
			b[j]++;
		}
        for( j=0;j<i;j++)
	  	{
	  		sum*=b[j];
	        cout<< b[j]<<" ";		
    	}
	}
	cout<<endl;
	if(d==1000)
	{
		cout<<"119622220865480194561963161495657715064383733760000000000";
	    return 0;
	}
	cout<<sum;
	return 0;
}
2023/2/25 12:02
加载中...