HDU1284钱币兑换问题
来源:互联网 发布:淘宝的的vx是什么意思 编辑:程序博客网 时间:2024/04/30 09:36
题目——传送
#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;int dp[32768];int main(){ int i,j,n; int val[3]= {1,2,3}; memset(dp,0,sizeof(dp)); dp[0] = 1; for(i=0; i<3; i++) { for(j=val[i]; j<=32768; j++) { dp[j] = dp[j]+dp[j-val[i]]; } } while(~scanf("%d",&n)) { printf("%d\n",dp[n]); } return 0;}
数学方法也过
#include<stdio.h>int main(){long i,n,sum,f;while(scanf("%ld",&n)>0){sum=0;sum+=n/3; //计算n换成3、1的有多少种sum++; //n全部换成1的for(i=0;i<=n/3;i++){f=(n-i*3)/2; //n换成2的有多少种,先是换出一个3,再是将剩下的2换成1,相加,得到结果,也不必担心重复计算的问题sum+=f;}printf("%ld\n",sum);}return 0;}
0 0
- hdu1284(钱币兑换问题)
- HDU1284:钱币兑换问题
- HDU1284 钱币兑换问题
- HDU1284-钱币兑换问题
- HDU1284钱币兑换问题
- HDU1284-钱币兑换问题
- hdu1284钱币兑换问题
- HDU1284 钱币兑换问题
- HDU1284:钱币兑换问题
- hdu1284经典钱币兑换问题
- HDU1284 钱币兑换问题,背包问题
- HDU1284——钱币兑换问题
- HDU1284:钱币兑换问题(完全背包)
- HDU1284--钱币兑换问题 HDU(103)
- hdu1284钱币兑换问题(母函数)
- hdu1284-钱币兑换问题(简单dp)
- hdu1284 钱币兑换问题(完全背包)
- hdu1284钱币兑换问题 (普通型母函数)
- linux free命令中buffer与cache的区别
- Android开发环境搭建 总结
- android 用release key 发布 百度地图
- cocos2dx schedule可延时的for循环 scheduleonce的问题
- 【cocos2d-x3.2游戏开发】 lua 类, 继承, 面向对象
- HDU1284钱币兑换问题
- POJ 1637 Sightseeing tour (混合图欧拉回路)
- js中 opener和parent的区别
- air max pas cher and put her purse snatched the phone. "The girl said the man robbed not tall
- Java中super的几种用法并与this的区别
- toms outlet I asked you to go to the ballpark where the ballpark Yeah
- giuseppe shoes the child has been successfully vaccinated in Shaanxi
- 总结一下Android Handler机制。
- louboutin men driven by large 4G terminals development of. At present