码迷,mamicode.com
首页 > 其他好文 > 详细

练习备份5

时间:2018-04-20 13:31:36      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:bsp   def   class   turn   lse   nbsp   return   col   ++   

#include<stdio.h>
#define maxn 1001
int flag=0;
long long f[2][maxn*maxn];
void DP(int n)
{
    f[flag][0]=1;
    for(int i=1;i<n;i++)
    {
        flag=1-flag;
        for(int j=0;j<=i*(i+1)/2;j++)
        {
            if(i>j) f[flag][j]=f[1-flag][j];
            else if(i<=j) f[flag][j]=f[1-flag][j-i]+f[1-flag][j];
            f[flag][j]%=100000007;
        }    
    }    
} 
int main(void)
{
    int n,s,a,b;
    long long temp,cnt=0;
    scanf("%d%d%d%d",&n,&s,&a,&b);
    DP(n);
    for(long long i=0;i<=n*(n-1)/2;i++)
    {
        temp=s+b*(n-1)*n/2-b*i-a*i;
        if(temp%n==0)
        {
            cnt+=f[flag][i];
            cnt%=100000007;
        }
    }
    printf("%lld",cnt);
    return 0;
}

 

练习备份5

标签:bsp   def   class   turn   lse   nbsp   return   col   ++   

原文地址:https://www.cnblogs.com/zuimeiyujianni/p/8889605.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!