社区讨论

求救

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

讨论操作

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

当前回复
3 条
当前快照
1 份
快照标识符
@lo8ui2uh
此快照首次捕获于
2023/10/28 00:46
2 年前
此快照最后确认于
2023/10/28 00:46
2 年前
查看原帖
CPP
#include<bits/stdc++.h>
using namespace std;
const long long N=10e6+5;
int n=0,cnt=1;
long long a[2000][10],chk[10];
int f(int all,int a){
    if (a==10){
        if (all==n) {
            for(int j=1;j<=10;j++){
				a[cnt][j]=chk[j];
            }
            cnt++;
        }
    }else{
    	for(int i=1;i<=3;i++){
        	chk[a]=i;
        	f(all+i,a+1);
    	}
  	}
}
int main(){
	cin>>n;
	if(n>30||n<10){
		cout<<"0"<<endl;
		return 0;
	}else{
		f(0,0);
	}
	cout<<cnt-1<<endl;
	for(int i=1;i<=cnt;i++){
		for(int j=1;j<=10;j++){
			cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}
	return 0;
}

CE了
CPP
[Error] invalid types 'int[int]' for array subscript 
求救

回复

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

正在加载回复...