POJ 3187 Backward Digit Sums (递推,bruteforce)
第1行j列的一个1加到最后1行满足杨辉三角,可以先推出组合数来
然后next_permutation直接暴。
- #include<cstdio>
- #include<iostream>
- #include <iterator>
- #include<string>
- #include<cstring>
- #include<queue>
- #include<vector>
- #include<stack>
- #include<vector>
- #include<map>
- #include<set>
- #include<algorithm>
- using namespace std;
- int n,tar;
- const int maxn = ;
- int a[maxn];
- int C[maxn][maxn];
- inline bool ok()
- {
- int re = ;
- for(int i = ; i < n; i++){
- re += a[i]*C[n-][i];
- }
- return re == tar;
- }
- //#define LOCAL
- int main()
- {
- #ifdef LOCAL
- freopen("in.txt","r",stdin);
- #endif
- for(int i = ; i < maxn; i++){
- C[i][] = C[i][i] = ;
- for(int j = ; j < i; j++){
- C[i][j] = C[i-][j] + C[i-][j-];
- }
- }
- scanf("%d%d",&n,&tar);
- for(int i = ; i < n; i++)a[i] = i+;
- while(!ok() && next_permutation(a,a+n));
- copy(a, a + n, ostream_iterator<int>(cout, " "));
- return ;
- }
POJ 3187 Backward Digit Sums (递推,bruteforce)的更多相关文章
- POJ 3187 Backward Digit Sums 枚举水~
POJ 3187 Backward Digit Sums http://poj.org/problem?id=3187 题目大意: 给你一个原始的数字序列: 3 1 2 4 他可以相邻 ...
- 穷竭搜索:POJ 3187 Backward Digit Sums
题目:http://poj.org/problem?id=3187 题意: 像这样,输入N : 表示层数,输入over表示最后一层的数字,然后这是一个杨辉三角,根据这个公式,由最后一层的数,推出第一行 ...
- poj 3187 Backward Digit Sums(穷竭搜索dfs)
Description FJ and his cows enjoy playing a mental game. They write down the numbers to N ( <= N ...
- POJ 3187 Backward Digit Sums
暴力DFS+验证. 验证如果是暴力检验可能复杂度会太高,事实上可以o(1)进行,这个可以o(n*n)dp预处理. #include<cstdio> #include<cstring& ...
- POJ 3187 Backward Digit Sums (dfs,杨辉三角形性质)
FJ and his cows enjoy playing a mental game. They write down the numbers from 1 to N (1 <= N < ...
- Backward Digit Sums(POJ 3187)
Backward Digit Sums Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5495 Accepted: 31 ...
- 【POJ - 3187】Backward Digit Sums(搜索)
-->Backward Digit Sums 直接写中文了 Descriptions: FJ 和 他的奶牛们在玩一个心理游戏.他们以某种方式写下1至N的数字(1<=N<=10). 然 ...
- BZOJ1653: [Usaco2006 Feb]Backward Digit Sums
1653: [Usaco2006 Feb]Backward Digit Sums Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 207 Solved: ...
- Backward Digit Sums(暴力)
Backward Digit Sums Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5664 Accepted: 32 ...
随机推荐
- QuotaExceededError: The quota has been exceeded. localStorage缓存超出限制
今天在项目中遇到了一个问题,localStorage存储超出限制.报错信息如标题.这个是因为最近做了一波优化,把导航栏和一些用户信息本地化存储,都放在localStorage里,也不是每个用户会出现这 ...
- EasyUI/TopJUI之如何动态改变下拉列表框ComboBox输入框的背景颜色
简单记录一下 前段时间接到客户需求:动态改变下拉列表框ComboBox输入框的背景颜色. 刚开始想的很简单在用户选择列表项的时候,判断一下列表框的value值添加相应的背景颜色就OK了,然而在实际操作 ...
- I/O重定向和管道
一:I/O设备 I/O(Input/Output),即输入/输出,通常指数据在内部存储器和外部存储器或其他周边设备之间的输入和输出. 标准输入(STDIN):0 默认接受来自键盘的输入 标准输出(ST ...
- idea中导入githup项目
转载大神: https://blog.csdn.net/m0_37630602/article/details/69950528
- C# 枚举类型 enum (一)
1.枚举使用enum关键字来声明,与类同级.枚举可以和类并列也可以 写在类里面,不能写在方法里. 2.枚举是值类型,隐式继承自System.Enum,不能手动修改. System.Enum本身是引用类 ...
- Unity PlayerPrefs
对于游戏存档,储存最高分,排行榜都需要用到储存,现在存储的方式有很多,可以存本地的Json,XML,Sqlite,还有一种就是unity自带的一种存储PlayerPrefs. 那么这个PlayerPr ...
- Linux系统的vim编辑器的配置文件的初步说明
vim 编辑器的基本说明 vi编辑器的功能类似于Windows下的记事本,只能编辑普通文本,而vim编辑器则相当于Windows下的notepad++等高级编辑器,提升了代码开发效率. 将vi命令默认 ...
- IDEA/Eclipse安装 Alibaba Java Coding Guidelines 插件
为了让开发者更加方便.并且达到快速规范代码格式的目的并实行起来,阿里巴巴基于<阿里巴巴Java开发规约>手册内容,研发了一套自动化的IDE检测插件(IDEA.Eclipse).它就是Ali ...
- CentOS6.5安装配置详解
1. 环境要求 VMWare软件: CentOS6.5对应的iso镜像文件(位数对应个人计算机位数). 2. 安装步骤 打开VMWare,文件->新建虚拟机(以下几步默认跳过即可) 命名和选择安 ...
- linux上的shutdown命令
定时关机:shutdown -r now 立刻重新开机 shutdown -h now 立刻关机 shutdown -k now 'Hey! Go away! now....' 发出警告讯息, 但没有 ...