We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#include<bits/stdc++.h>#define P 1000000007usingnamespacestd;unsignedlonglongintgetWays(intn){vector<unsignedlonglongint>a(n+1);a[0]=1;for(intj=1;j<n;j++){for(inti=j;i<=n;i++){a[i]+=a[i-j]%P;}}returna[n]%P;}intmain(){intt,n;cin>>t;for(inti=0;i<t;i++){cin>>n;// Print the number of ways of making change for 'n' units using coins having the values given by 'c'unsignedlonglongintways=getWays(n);cout<<ways<<endl;}return0;}
Project Euler #76: Counting summations
You are viewing a single comment's thread. Return to all comments →