CF1153F Serval and Bonus Problem[通俗易懂]

CF1153F Serval and Bonus Problem[通俗易懂]CF1153F Serval and Bonus Problem

大家好,又见面了,我是你们的朋友全栈君。

 Serval and Bonus Problem

1.转化为l=1,最后乘上l

2.对于一个方案,就是随便选择一个点,选在合法区间内的概率

3.对于本质相同的所有方案考虑在一起,贡献就是合法区间个数/(2*n+1)

4.运用条件概率或者直接解释,只需求出所有本质不同的方案的合法区间个数的和

5.DP即可。

#include<bits/stdc++.h>
#define reg register int
#define il inline
#define fi first
#define se second
#define mk(a,b) make_pair(a,b)
#define numb (ch^'0')
using namespace std;
typedef long long ll;
template<class T>il void rd(T &x){
    char ch;x=0;bool fl=false;
    while(!isdigit(ch=getchar()))(ch=='-')&&(fl=true);
    for(x=numb;isdigit(ch=getchar());x=x*10+numb);
    (fl==true)&&(x=-x);
}
template<class T>il void output(T x){
   
   if(x/10)output(x/10);putchar(x%10+'0');}
template<class T>il void ot(T x){
   
   if(x<0) putchar('-'),x=-x;output(x);putchar(' ');}
template<class T>il void prt(T a[],int st,int nd){
   
   for(reg i=st;i<=nd;++i) ot(a[i]);putchar('\n');}

namespace Miracle{
const int N=4008;
const int mod=998244353;
int n,k,l;
int qm(int x,int y){
    int ret=1;
    while(y){
        if(y&1) ret=(ll)ret*x%mod;
        x=(ll)x*x%mod;
        y>>=1;
    }
    return ret;
}
int ad(int x,int y){
    return x+y>=mod?x+y-mod:x+y;
}
int f[N][N][2];
int main(){
    rd(n);rd(k);rd(l);
    f[0][0][0]=1;
    for(reg i=1;i<=2*n+1;++i){
        for(reg j=0;j<=i;++j){
            for(reg x=0;x<=1;++x){
                if(i+j+(1-x)<=2*n+1){
                    // cout<<i<<" "<<j<<" "<<x<<endl;
                    f[i][j][x]=ad(f[i][j][x],(ll)f[i-1][j+1][x]*(j+1)%mod);
                    if(j>0)f[i][j][x]=ad(f[i][j][x],f[i-1][j-1][x]);
                    if(x==1&&j>=k)f[i][j][x]=ad(f[i][j][x],f[i-1][j][0]);
                    // cout<<" val "<<f[i][j][x]<<endl;
                }
            }
        }
    }
    // cout<<f[2*n+1][0][1]<<endl;
    ll jie=1;
    for(reg i=n+1;i<=2*n+1;++i) jie=(ll)jie*i%mod;
    ll ans=(ll)f[2*n+1][0][1]*qm(2,n)%mod*qm(jie,mod-2)%mod;
    cout<<(ll)ans*l%mod;
    return 0;
}

}
signed main(){
    Miracle::main();
    return 0;
}

/*
   Author: *Miracle*
   Date: 2019/4/13 19:58:12
*/

 

转载于:https://www.cnblogs.com/Miracevin/p/10713639.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/106876.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 一起学习Spring boot 2.1.X | 第五篇:Mybatis Druid 数据库(注解版)「建议收藏」

    一起学习Spring boot 2.1.X | 第五篇:Mybatis Druid 数据库(注解版)「建议收藏」运行展示正题Springboot:2.1.5RELEASE;数据库(Mysql、Oracle);Mybatis;阿里云的连接池:Druid;步骤1.POM依赖<!–MyBatis–><dependency><groupId>org.mybatis.spring.boot</groupId>…

    2022年7月23日
    16
  • ddl dml语句_用一句话介绍自己怎么介绍

    ddl dml语句_用一句话介绍自己怎么介绍数据库定义语言对数据库的操作对表的操作对字段,约束的操作DML语句表中数据增加,删除,修改总结提示:这里对文章进行总结:例如:以上就是今天要讲的内容,本文仅仅简单介绍了pandas的使用,而pandas提供了大量能使我们快速便捷地处理数据的函数和方法。…

    2022年10月19日
    3
  • spark scheduler_scheduledthreadpool

    spark scheduler_scheduledthreadpoolSpark的TaskScheduler和DagScheduler开始研究神奇的spark。会陆续将研究的心得放上来。在Spark中一个核心的是模块就是调度器(Scheduler),在spark中Scheduler有两种TaskScheduler(是低级的调度器接口),DagScheduler(是高级的调度)我们在创建SparkContext对象的时候,sparkcontext内部就会创建Ta…

    2022年10月10日
    7
  • c语言code用法_visual code c语言

    c语言code用法_visual code c语言此文章出处:http://www.cppblog.com/izualzhy/archive/2012/07/09/182456.html先看个例子:汉字一的UTF-8编码为0xE40xb80x80我们在google里搜索一下“一”,地址栏显示为:可以看到url的字符串里有一个%E4%B8%80这就是encode之后的值。因此,encode的处理过程也很明显了。特别是传中文参数时,如果没…

    2022年9月28日
    3
  • Vim插件管理:Pathogen安装

    Vim插件管理:Pathogen安装vim管理插件工具pathogen安装

    2025年8月7日
    3
  • 统计学的Python实现-016:变异系数

    统计学的Python实现-016:变异系数作者:长行时间:2019.03.15统计学解释变异系数:变异系数(coefficientofvariation),又称离散系数,是一个衡量数据离散程度的、没有量纲的统计量。其值为标准差与平均值之比。变异系数的计算公式为:CV=σμCV=\frac{\sigma}{\mu}CV=μσ​其中σ\sigmaσ为标准差,μ\muμ为均值。代码实现importnumpydefcoefficient_of_variation(data):mean=numpy.mean(dat.

    2022年5月29日
    75

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号