Sicily2014
来源:互联网 发布:中文字体软件 编辑:程序博客网 时间:2024/06/06 09:08
DP算法:
#include <iostream>#include <cstdio>using namespace std;int main(){int m,n;scanf("%d%d",&m,&n);int dp[305]={0};int i,j;int A[10];for (i=n;i>=1;i--)scanf("%d",&A[i]);//dpdp[0]=1;for (i=1;i<=n;i++)for (j=1;j<=m;j++){if (j>=A[i])dp[j]+=dp[j-A[i]];}printf("%d\n",dp[m]);return 0;}
#include <iostream>#include <cstdio>using namespace std;int ans=0;int A[10];int m,n;void dfs(int total,int pos){ if (pos>n-1) return; while (1) { if (total==m) { ans++; break; } dfs(total,pos+1); if (total+A[pos]<=m) total+=A[pos]; else break; }}int main(){ scanf("%d%d",&m,&n); int i; for (i=0;i<=n-1;i++) scanf("%d",&A[i]); dfs(0,0); printf("%d\n",ans); return 0;}
0 0
- Sicily2014
- 第十九周:( Sicily2014) Dairy Queen(c++)
- sql 优化
- eclipse启动tomcat
- U_BOOT_CMD 分析
- error: more than one device and emulator
- 读书笔记:持续集成软件质量改进和风险降低之道-第三章 和第四章
- Sicily2014
- IDS(入侵检测系统)
- jsaper导出的excel自动适应长度
- 李天平:技术以外的功夫
- android中常见对话框之一AlertDialog
- Android Http抓包
- phonegap自定义插件 笔记
- 详解C中volatile关键字
- 自定义简单的工具栏类(真彩色)