the problem is about coin change - "how many ways you can change 3,5,10 dollars if you have 5c,10c ...... "http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=83 the problem is solved many times on various blogs( solution [here](http://jijingshanlin.blogspot.ca/2012/07/147-dollars.html) ) In dp, the hardest thing is to understand the relation between subproblems and get the formula(optimal substructure) I only give the actual for loop that stores the ways into 2d table like the solution: for (int i = 2; i <= NCHANGES; ++i){ for (int m = 1; m <= MAX_AMOUNT; ++m){ if (m >= coins[i]) n[i][m] = n[i-1][m] + n[i][m - coins[i]]; else n[i][m] = n[i-1][m]; … +0 A solution for the "Hartals" problem. Problem description: http://icpcres.ecs.baylor.edu/onlinejudge/external/100/10050.html Author: [Joana Matos Fonseca da Trindade](http://joanatrindade.wikidot.com) #include int main() { int i,j,k,a,b,h,hd,n,p,pd,tc,t,s; while(scanf("%d",&tc)==1) { for(i=0;i=a;b--) if(hd[b-1]>hd[b]) { t=hd[b-1]; hd[b-1]=hd[b]; hd[b]=t; } for(t=1;t

The End.