Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #define INFINITO 100000000
- int menor(int a,int b)
- {
- if(a<=b)
- return a;
- else
- return b;
- }
- int main(int argc, char const *argv[])
- {
- int t,m,nSize,i,j;
- int n[26];
- int parcial[1000001];
- scanf("%d",&t);
- while(t--)
- {
- scanf("%d %d",&nSize,&m);
- for (i = 0; i < nSize; i++)
- scanf("%d",&n[i]);
- parcial[0]=0;
- for (i = 1; i <= m; i++)
- {
- parcial[i] = INFINITO;
- for(j=0;j<nSize;j++)
- {
- if(n[j] <= i)
- {
- parcial[i] = menor(parcial[i],parcial[i-n[j]]+1);
- }
- }
- }
- printf("%d\n",parcial[m]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement