2009年10月18日 星期日

UVa 357 Let Me Count The Ways

357    Let Me Count The Ways    Accepted    C++    0.012    2009-10-18 07:31:20                       .

唔破了一次AC  QQ


有注意到是long long但是沒有處理0

然後忘了改%lld 好幾次WA

還有一個不小心刪了一個空白吃了UVa第一個PE

//***********************************

#include <stdio.h>
long long dp[30500];
int coin[5]={1,5,10,25,50},n;
main(){
    for(int i=0;i<5;i++){
        dp[coin[i]]++;
        for(int j=0;j<30010;j++)
            dp[j+coin[i]]+=dp[j];
    }
    while(~scanf("%d",&n))
        dp[n]>1?printf("There are %lld ways to produce %d cents change.\n",dp[n],n):printf("There is only 1 way to produce %d cents change.\n",n);
}


沒有留言:

張貼留言