暴力50分求助
  • 板块P2089 烤鸡
  • 楼主spessert
  • 当前回复2
  • 已保存回复2
  • 发布时间2024/3/16 11:30
  • 上次更新2024/3/16 14:10:32
查看原帖
暴力50分求助
881317
spessert楼主2024/3/16 11:30

2、7、8、9、10测试点显示RE

#include<iostream>
#include<string>
using namespace std;
int sum[1000][100],la=0;  //二维数组存值
int ans=0; 
int main()
{
    int n;
    cin>>n;
    int a,b,c,d,e,f,g,h,i,j;
    
    for(a=1;a<=3;a++)
     for( b=1;b<=3;b++)
      for(c=1;c<=3;c++)
       for(d=1;d<=3;d++)
        for(e=1;e<=3;e++)
         for(f=1;f<=3;f++)
          for(g=1;g<=3;g++)
           for(h=1;h<=3;h++)
            for( i=1;i<=3;i++)
             for( j=1;j<=3;j++){
             	if((a+b+c+d+e+f+g+h+i+j)==n){
             		ans++;
    		
             		for(int ii=0;ii<10;ii++){
             			int temp;
             			if(ii==0) temp=a;
             			else if(ii==1) temp=b;
             			else if(ii==2) temp=c;
             			else if(ii==3) temp=d;
             			else if(ii==4) temp=e;
             			else if(ii==5) temp=f;
             			else if(ii==6) temp=g;
             			else if(ii==7) temp=h;
             			else if(ii==8) temp=i;
             			else  temp=j;
             			sum[la][ii]=temp;
             			
             		}
             		la++;
             	}
             }
             
      cout<<ans<<endl;
      
      if(ans!=0)
       for(int i=0;i<la;i++){
      	for(int j=0;j<10;j++){
      		if(j==9) cout<<sum[i][j];
      		else cout<<sum[i][j]<<" ";
      	}
      	cout<<endl;
      }
    return 0;
}
2024/3/16 11:30
加载中...