hdu 2152 (모 함수 입문)

제목 링크: hdu 2152
모 함수 템 플 릿
#include
using namespace std;
#define FFF freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
#define lson l,m,r<<1
#define rson m+1,r,r<<1|1
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define maxn 200
typedef long long ll;
typedef pair<int,int>pii;
typedef pairpll;
typedef pair<double,double>pdd;
typedef pair<double ,int>pdi;
const int INF=0x3f3f3f3f;
const int MOD=1e9+7;
int main()
{
    ios::sync_with_stdio(false);
    #ifndef ONLINE_JUDGE
    FFF
    #endif // ONLINE_JUDGE
    int n,m;
    int up[maxn],down[maxn];
    while(cin>>n>>m)
    {
        if(!n&&!m)break;
        for(int i=0;icin>>down[i]>>up[i];
        int c1[maxn]={0};
        int c2[maxn]={0};
        for(int i=down[0];i<=up[0];i++)c1[i]=1;
        for(int i=1;i//        
        {
            for(int j=0;j<=m;j++)//           , 0       
            {
                for(int k=down[i];k+j<=m&&k<=up[i];k++)//         a[i]  ,  i         ,           
                    c2[k+j]+=c1[j];
            }
            memcpy(c1,c2,sizeof(c1));
            CLR(c2,0);
        }
        cout<return 0;
}

좋은 웹페이지 즐겨찾기