社区讨论

30pts求调(壶关)

P2089烤鸡参与者 2已保存回复 5

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
5 条
当前快照
1 份
快照标识符
@mhj3k6ug
此快照首次捕获于
2025/11/03 20:09
4 个月前
此快照最后确认于
2025/11/03 20:09
4 个月前
查看原帖
CPP
#include<bits/stdc++.h>
using namespace std;
int n,s,l[1001][11];
int main(){
    scanf("%d",&n);
    for(int a=1;a<4;a++)
      for(int b=1;b<4;b++)
        for(int c=1;c<4;c++)
          for(int d=1;d<4;d++)
            for(int e=1;e<4;e++)
              for(int f=1;f<4;f++)
                for(int g=1;g<4;g++)
                  for(int h=1;h<4;h++)
                    for(int i=1;i<4;i++)
                      if(a+b+c+d+e+f+g+h+i==n){
                          s++;
                          l[s][1]=a,l[s][2]=b,l[s][3]=c,l[s][4]=d,l[s][5]=e;
                          l[s][6]=f,l[s][7]=g,l[s][8]=h,l[s][9]=i;
                      }
    printf("%d",s);
    for(int i=1;i<=s;i++){
        printf("\n");
        for(int j=1;j<11;j++) printf("%d ",l[i][j]);
    }
    return 0;
}

回复

5 条回复,欢迎继续交流。

正在加载回复...