Codeforces Round #437 (Div. 2) B. Save the problem!
来源:互联网 发布:spark als推荐算法 编辑:程序博客网 时间:2024/05/17 16:46
题意:
给你一个数字A,要你给出一个价格和一堆硬币种类,要让这些硬币组成这个价格的方案数为A
思路:
想了很久没想出来,答案是除了A是1的时候,价格都是2*(A-1),硬币只有1和2,因为,你用(A-1)个2元0个1元,然后是(A-2)个2个1元,这样方案数就相当于A-1减到0,共A种,真的有点巧妙。。。
错误及反思:
其实自己写个完全背包打表也许能看出规律吧,可惜完全没往这个方向想
代码:
#include<bits/stdc++.h>using namespace std;int main(){ int n; scanf("%d",&n); if(n==1) printf("1 1\n1\n"); else printf("%d 2\n1 2\n",(n-1)*2);}
阅读全文
0 0
- Codeforces Round #437 (Div. 2) B. Save the problem!
- Codeforces Round #437 (Div. 2) B 865ASave the problem! (思维)
- Codeforces Round #170 (Div. 2) problem B
- Codeforces Round #173 (Div. 2) Problem B
- Codeforces Round #311 (Div. 2) Problem B
- Codeforces Round #363 (Div. 2), problem: (B)
- CodeForces 867B Save the problem!
- Problem E Codeforces Round #184 (Div. 2) B. Continued Fractions
- Problem G B. Calendar Codeforces Round #183 (Div. 2)
- Codeforces Round #196 (Div. 2) B. Routine Problem
- Codeforces Round #196 (Div. 2) / 337B Routine Problem(数学)
- Codeforces Round #196 (Div. 2) B. Routine Problem
- Codeforces Round #FF (Div. 2) Problem B DZY Loves Strings
- Codeforces Round #170 (Div. 2) B. New Problem
- Codeforces Round #279 (Div. 2), problem: (B) Queue
- Codeforces Round #343 (Div. 2) B. Far Relative’s Problem
- Codeforces Round #343 (Div. 2) Problem A & B
- Codeforces Round #343 (Div. 2) B. Far Relative’s Problem
- 关于const的相关知识
- javascript中==与===的区别
- 习题七
- Linux下ssh登陆密码端口用户等基本修改
- Ubuntu 16.04 启动栏或者状态栏的位置切换命令
- Codeforces Round #437 (Div. 2) B. Save the problem!
- 五、My SQL 数据库 (一)建表规约
- python : 蒙特卡罗算法 应用于双色球
- 链路层基本问题 : 封装成帧、差错检测、流量控制
- phpcms二次开发
- NWERC2015 Kitchen Combinatorics
- hdu-2157-How many ways??【矩阵快速幂】
- HDU 4417 主席树
- HDU-4587 TWO NODES(割点变形或者求点双连通分量)