P2089 烤鸡 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
鼠鼠我啊也想吃烤鸡
循环枚举,就是循环的有一点点多,多到不太敢写(阿巴阿巴).......真是够暴力的呢
使用ios::sync_with_stdio(false)即可我部畅通无阻,畅通无阻!
输个20,看看电脑实力doge,8953种情况
#include<iostream>
using namespace std;
int main(){
std::ios::sync_with_stdio(false);
int n,k,ans=0;
cin>>n;
int m[10000][10];
for(int a=1;a<=3;a++){
for(int b=1;b<=3;b++){
for(int c=1;c<=3;c++){
for(int d=1;d<=3;d++){
for(int e=1;e<=3;e++){
for(int f=1;f<=3;f++){
for(int g=1;g<=3;g++){
for(int h=1;h<=3;h++){
for(int i=1;i<=3;i++){
for(int j=1;j<=3;j++){
k=a+b+c+d+e+f+g+h+i+j;
if(k==n){
ans++;
m[ans][0]=a;
m[ans][1]=b;
m[ans][2]=c;
m[ans][3]=d;
m[ans][4]=e;
m[ans][5]=f;
m[ans][6]=g;
m[ans][7]=h;
m[ans][8]=i;
m[ans][9]=j;
}
}
}
}
}
}
}
}
}
}
}
cout<<ans<<endl;
for(int i=1;i<=ans;i++){
for(int j=0;j<=9;j++){
cout<<m[i][j]<<" ";
}
cout<<endl;
}
}
看题解时看到一种queue(队列)的做法,stl容器,之前见过vector(向量),看来接下来要去见识一下stl库函数了,感觉有时候可比数组好用多了。
诶,今天好像是.........
为防止大家长期摸鱼导致变笨,特此准备了几道题考考!
1.至今思项羽,不()过江东。
2.阳春布()泽,万物生光辉。
3.书籍是人类进步的阶梯。——高尔( )
4.世人笑我太()癫,我笑他人看不穿。
5.老夫聊发少年(),左牵黄,右擎苍。
6.危楼高百尺,手可摘()辰。
7.君问归期未有( ),巴山夜雨涨秋池。
8.( )面边声连角起,千嶂里,长烟落日孤城闭。
9.料峭春风吹酒醒,( )冷,山头斜照却相迎。
10.( )闻琵琶已叹息,又闻此语重唧唧。
11.锦瑟无端()()弦,一弦一柱思华年。
我的烤鸡在哪呢?~