UVA 674 - Coin Change

UVA Sep 1, 2020

Problem PDF

Solution:

#include
#include
long long Mod = 100000007;
int main()
{
       long long coin[6]={1,5,10,25,50},way[7510]={0},i,j,a;
        way[0]=1;
        for(i=0;i<5;i++)
        {
          for(j=coin[i];j<=7500;j++)
          {
                way[j]+=way[j-coin[i]];
                if(way[j]>=Mod)
                way[j]%=Mod;
          }
        }
        while(scanf("%lld",&a)==1)
        {
           printf("%lld\n",way[a]);
        }
    return 0;
}

https://github.com/Shipu/OnlineJudgeProblemSolutionWithCPlusPlus/tree/master/uva/674/674.cpp

Tags

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.