【POJ】3187
来源:互联网 发布:新京报网络直播回看 编辑:程序博客网 时间:2024/06/06 03:54
http://poj.org/problem?id=3187
输入n,sum,按杨辉三角的规则,求1~n的数。
全排列
#include <iostream>#include <cstdio>#include <cstring> #include <algorithm>using namespace std;int n,sum;int a[20],b[20];int main(){ while (cin >> n >> sum){ for (int i=1;i<=n;i++){ a[i]=i; } do{ for (int i=1;i<=n;i++){ b[i]=a[i]; } for (int i=n-1;i>=1;i--){ for (int j=1;j<=i;j++){ b[j]+=b[j+1]; } } if (b[1]==sum) break; }while (next_permutation(a+1,a+1+n)); for (int i=1;i<=n;i++){ cout << a[i] << " "; } cout << endl; }}
阅读全文
0 0
- poj 3187
- poj 3187
- poj 3187
- poj 3187
- POJ 3187
- 【POJ】3187
- POJ 3187 爆搜
- poj 3187 (康托逆展开)
- POJ 3187 (DFS)
- 【poj】3187全排列
- POJ
- poj
- POJ
- POJ
- poj
- poj
- POJ
- POJ
- html ul li数目太多不会滚动的超出屏幕看到不到的解决方案
- svg js给group text添加超链接&改变鼠标形状
- EasyUI进度条 后台实时监控
- springboot中通过aop的形式获取方法执行时间
- 获取远程文件大小
- 【POJ】3187
- 认识glBegin
- 补充使用SDK 修改VM OPTION的细节
- 关于Email地址验证的正则表达式
- PCL滤波III
- xamarin android 如何创建一个服务
- 设计模式-状态模式
- 图像增强(锐化)相关算子
- 系统开发简易流程(升级版)