Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(int argc, char** argv) {
- int n;
- int coins[] = {1,5,10,25,50};
- unsigned long long int ways[30005];int i;int j;
- ways[0]=1;int coin;
- for (i=0;i<5;i++){
- coin = coins[i];
- for(j=coin;j<30005;j++){
- ways[j]=ways[j]+ways[j-coin];
- }
- }
- while(scanf("%d",&n)==1){
- if (ways[n]>1){
- printf("There are %llu ways to produce %d cents change.\n",ways[n],n);
- }else{
- printf("There is only 1 way to produce %d cents change.\n",n);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement