Topic Link: Click to open the link
Change the coin problem. But there are points, so it is a decimal input, at first because of the accuracy problem WA pitch. And.. Count with a long long.
#include <algorithm> #include <iostream> #include <cstring> #include <cstdlib> #include < string> #include <cctype> #include <vector> #include <cstdio> #include <cmath> #include < queue> #include <stack> #include <map> #include <set> #define MAXN 1005#define _ll __int64#define ll Long long#define INF 0x3f3f3f3f#define Mod 1<<40+10#define pp pair<int,int> #define ull unsigned long longusin G namespace Std;int v[]={10000,5000,2000,1000,500,200,100,50,20,10,5};ll dp[30010];d ouble n;void Solve () {memset (dp,0 , sizeof (DP));DP [0]=1;int m= (int) (n*100+0.5); for (int. i=0;i<11;i++) for (int j=v[i];j<=m;j++) dp[j]+=dp[j-v[i]]; printf ("%6.2lf%17lld\n", N,dp[m]);} int main () {while (~scanf ("%lf", &n) &&n) solve (); return 0;}
Uva 357: Click to open link
The same change money problem, put a dozen watch.
#include <algorithm> #include <iostream> #include <cstring> #include <cstdlib> #include < string> #include <cctype> #include <vector> #include <cstdio> #include <cmath> #include < queue> #include <stack> #include <map> #include <set> #define MAXN 1005#define _ll __int64#define ll Long long#define INF 0x3f3f3f3f#define Mod 1<<40+10#define pp pair<int,int> #define ull unsigned long longusin G namespace Std;int v[]={1,5,10,25,50};ll dp[30002];int n;void init () {memset (dp,0,sizeof (DP));DP [0]=1;for (int i=0;i <5;i++) for (int j=v[i];j<=30000;j++) dp[j]+=dp[j-v[i];} int main () {init (); while (~SCANF ("%d", &n)) {if (dp[n]!=1) printf ("There is%lld ways to produce%d cents change.\n", dp[ N],n); elseprintf ("There is the only 1-to produce%d cents change.\n", n);} return 0;}
Uva 147-dollars (DP)