Advertisement
shamiul93

UVa 147 - Dollars

Mar 9th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.32 KB | None | 0 0
  1. /**
  2. @author - Rumman BUET CSE'15
  3. problem - UVA 147 - Dollars
  4.  
  5. */
  6. #include<bits/stdc++.h>
  7. #define ll long long
  8. #define fo freopen("out.txt","w",stdout)
  9. #define fi freopen("in.txt","r",stdin)
  10. #define DEBUG printf("hi\n");
  11. #define DEBUG2 printf("bi\n");
  12. #define pi acos(-1)
  13. //#define m 100000007
  14. #define d 0.000000001
  15.  
  16. using namespace std ;
  17.  
  18. ll curr[] = { 2000, 1000, 400, 200, 100 , 40, 20, 10, 4, 2 ,1 }; ;
  19. ll dp[20][1000000] ;
  20.  
  21. ll rec(ll i , int n)
  22. {
  23.     if(n == 0)
  24.         return 1 ;
  25.     if(n < 0)
  26.         return 0 ;
  27.     if(i > 10 && n > 0)
  28.         return 0 ;
  29.  
  30.     if(dp[i][n]!=-1)
  31.         return dp[i][n] ;
  32.  
  33.     return dp[i][n] = rec(i , n - curr[i]) + rec(i+1 , n) ;
  34. }
  35.  
  36. int main()
  37. {
  38. //    fi ; fo ;
  39.     double m ;
  40.     int mk ;
  41.     memset(dp , -1 , sizeof(dp));
  42.  
  43.     while(scanf("%lf",&m) && m!=0)
  44.     {
  45.  
  46.         double k ;
  47. //        k = m*1000 ; ///
  48.         mk = m * 20  ;
  49. //        mk/=10 ;
  50. //        cout << m - mk << " " <<  m << " " <<  mk << endl ;
  51.  
  52. //printf("%d %f",mk , k);
  53.         ll ans ;
  54.         ans = rec(0 , mk) ;
  55.  
  56.         if(m < 10)
  57.         {
  58.             printf("  %.2f%17lld\n",m , ans) ;
  59.         }
  60.         else if(m < 100)
  61.         {
  62.             printf(" %.2f%17lld\n",m , ans) ;
  63.         }
  64.         else
  65.         printf("%.2f%17lld\n",m , ans) ;
  66.     }
  67.  
  68.     return 0 ;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement