coin change -- 679

  1. // dp --- coin change
  2. #include <iostream>
  3. #include <cstring>
  4. #include <stdio.h>
  5. using namespace std;
  6. int dp[7500];
  7. int main()
  8. {
  9. int iCoinW[5] = { 15102550 };  
  10. int iIn,i,j;   
  11. while ( cin >> iIn )
  12.     {
  13.     memset(dp,0,sizeof(dp));
  14.     dp[0] = 1;
  15.     for ( i=0 ; i<5 ; i++ )
  16.         for ( j=0 ; j<7490 ; j++ ) 
  17.             dp[j+iCoinW[i]] = dp[j+iCoinW[i]] + dp[j]; 
  18.     cout << dp[iIn] <<endl;        
  19.     }
  20. }

留言

這個網誌中的熱門文章

Codeforces --- string task

Uva 674 ---- coin change

codeforces 271A --- beautiful year