大家帮忙看下,在c++上测试数据是对的,为什么只有10分?
查看原帖
大家帮忙看下,在c++上测试数据是对的,为什么只有10分?
741022
B2214shengmin楼主2022/6/28 22:52

提交的链接:(https://www.luogu.com.cn/record/78063170)

代码:

#include<bits/stdc++.h>
using namespace std;
char str[1010];//高精str 
int m[1010],n,y[1010];//单精n 

void zuidachenji(int g){
	int f=2,s=0,w[1010],o=1;
	while(s<g){
		w[o]=f;
		s+=w[o];
		f++;o++;
	}
	int e=s-g;
	//cout<<"s="<<s<<" f="<<f<<" e="<<e<<endl;
	if(e==0){
		for(int j=2;j<=f;g++){
			cout<<j<<" ";
			y[j-1]=j;
		}
	}else{
		int l[1010];
		if(e==1){
			y[1]=1;
			y[f]=f-1; 
		}else{
			for(int j=1;j<=o;j++){
				int h=j;
				bool flag=0;
				if(w[j]==e){w[j]=0;h--;flag=1;}
				else {
					if(flag==1)h--;
					y[j]=w[h];
				}
			}
		}
		for(int j=1;j<=f-1;j++){
			if(y[j]!=0)cout<<y[j]<<" ";
		}
	}
} 

int main() {
	int q,uu=1;
	cin>>q;
	zuidachenji(q);
	cout<<endl;
	for(int i=1;i<=q;i++){
		if(y[i]!=0)uu=y[i]*uu;
	}
	cout<<uu;
	return 0;				
} 
2022/6/28 22:52
加载中...