//aarifshuvo ``CSEJU #include <bits/stdc++.h> #define ll long long #define SZ(x) ((int)(x).size()) #define scl(x) scanf("%lld", &x) #define scll(x,y) scanf("%lld %lld", &x, &y) #define ALL(x) (x).begin(),(x).end() #define REP(i,n) for(int i=0;i<n;i++) #define REV(i,n) for(int i=n-1;i>=0;i--) #define FOR(i,a,b) for(int i=a;i<=b;i++) #define pri(a) cout<<a<<endl #define prii(a,b) cout<<a<<" "<<b<<endl using namespace std; ll curr[] = {5,10,20,50,100,200,500,1000,2000,5000,10000}; ll intmny,dblmny; ll dp[12][303*100]; double xx; ll call(ll i, ll feas) { if(feas==0) return 1; if(i==11) return 0; if(dp[i][feas]!=-1) return dp[i][feas]; dp[i][feas]=0; for(int j=0; feas-j*curr[i]>=0 ;j++) { dp[i][feas] += call(i+1,feas - j*curr[i]); } return dp[i][feas]; } int main() { char ch; memset(dp,-1,sizeof dp); while(scanf("%lld %c %lld", &intmny, &ch, &dblmny)==3 and intmny+dblmny) { intmny = intmny*100 + dblmny; xx = (intmny*1.0)/100; ll res = call(0,intmny); printf("%6.2lf%17lld\n", xx, res); } return 0; }
~Be glad of life because it gives you the chance to love and to work and to play and to look at the stars.~
Thursday, June 1, 2017
UVa 147 Dollars
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment