朱色虫居
Pages
Home
Featured Posts
2006/10/01
674-Coin Change
/*
"Coin Change"
Level:6.0
Date:2006/9/30
技巧:Dynamic programming
參357
*/
#include
#define N 5
#define M 7495
main(){
int coin[N]={1,5,10,25,50};
long long table[M]={0};
int cent=0,
i=0,j=0;
table[0]=1;
for(i=0;i < N;i++){ for(j=coin[i];j < M;j++) table[j]+=table[j-coin[i]]; } while(scanf("%d",¢)==1){ /* 沒有加==1,會有Output Limit Exceeded */ /* 上傳ACM,%17I64d 要改成%17lld */ printf("%I64d\n",table[cent]); } }
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment