标签:ott turn main acm eof print for rip 组合
此博客链接:https://www.cnblogs.com/ping2yingshi/p/12380402.html
选课时间(150min)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2079
#include<stdio.h> #include<math.h> #include<stdlib.h> #include<string.h> int main() { int T; while (~scanf_s("%d",&T)) { int n, k; int a[9]; int b[11]; int c[40] = { 0 }; memset(c, 0, sizeof(c)); scanf_s("%d %d", &n,&k);//输入总分n,数量k for (int i=1;i<=k;i++)//读取学分a数量b { scanf_s("%d", &a[i]); scanf_s("%d", &b[i]); } c[0] = 1; for (int i = 1; i <= k; i++) {// for (int j = n; j >= a[i]; j--) {//分数 { for (int l = 1; l <=b[i]; l++)//数量 { if (j - a[i] * l >= 0) { c[j] = c[j] + c[j - a[i] * l]; } else break; } } } } printf("%d\n", c[n]); T--; } return 0; }
明天继续完成。
标签:ott turn main acm eof print for rip 组合
原文地址:https://www.cnblogs.com/ping2yingshi/p/12380402.html