hdoj2079

Problem : 2079 ( 选课时间(题目已修改,注意读题) )     Judge Status : Accepted
RunId : 2856592    Language : G++    Author : huwenbiao
Code Render Status : Rendered By HDOJ G++ Code Render Version 0.01 Beta
/***************************************************************\
*Author:Hu Wenbiao
*Created Time: Sun 22 Aug 2010 11:57:35 AM CST
*File Name: main.cpp
*Description:简单母函数
\***************************************************************/

//*========================*Head File*========================*\\

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
/*----------------------*Global Variable*----------------------*/
int
T,n,m,grade[
10][2],A[45],B[45];
//*=======================*Main Program*=======================*//
using namespace std;

int
main(){

//freopen("input","r",stdin);
scanf("%d",&T);
while
(T--){
scanf(
"%d%d",&n,&m);
for
(int i=
1;i<=m;i++)
scanf(
"%d%d",&grade[i][0],&grade[i][1]);
memset(A,
0,sizeof(A));
memset(B,
0,sizeof(B));
A[
0]=1;
for
(int i=
1;i<=m;i++){//第i门课
for(int j=0;j<=n;j++){//现在学分
for(int k=0;k<=grade[i][1];k++){
B[j+k*grade[i][
0]]+=A[j];
}
}

for
(int i=
0;i<=n;i++){
A[i]=B[i];
B[i]=
0;
}
}

printf(
"%d\n",A[n]);
}
}
posted @ 2010-08-22 12:19  open source  阅读(154)  评论(0编辑  收藏