usaco 2.3 money...自娱自乐版...
2012-11-13 17:05
211 查看
/* ID:chenjiong PROG:money LANG:C++ */ #include <stdio.h> #include <string.h> int V,N; int m[30]; int sum; long long cnt; void dfs(int cur,int s) { if ( sum > N ) return; if ( sum == N ) { cnt++; return; } int i; for ( i = s; i < V; i++) { sum += m[i]; dfs(cur + 1,i); sum -= m[i]; } } int main() { freopen("money.in","r",stdin); freopen("money.out","w",stdout); int i; scanf("%d%d",&V,&N); for ( i = 0; i < V; i++) scanf("%d",&m[i]); sum = 0; dfs(0,0); printf("%ld\n",cnt); return 0; }
相关文章推荐
- USACO 2.3 money
- usaco-2.3-money-pass
- USACO 2.3 Money Systems (money)
- usaco 2.3 money
- usaco 2.3 money--强悍题解2008.6.21
- USACO 2.3 货币系统(背包/生成函数)
- USACO 2.3 Controlling Companies (DFS)
- bzoj1708[Usaco2007 Oct]Money奶牛的硬币(背包方案数dp)
- USACO 2.3 Cow Pedigrees (nocows)
- [USACO2.3]奶牛家谱 Cow Pedigrees
- USACO 2.3 Cow Pedigrees
- USACO section2.3 Cow Pedigrees题解&代码
- USACO Money Systems Dp 01背包
- usaco 2.3 zerosum...
- USACO 2.3 Zero Sum
- USACO 2.3 concom
- USACO 2.3 Zero Sum (zerosum)
- USACO 2.3 Zero Sum
- usaco-2.3-concom-pass
- USACO section2.3 Zero Sum题解&代码