908D New Year and Arbitrary Arrangement
分析
代码
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
const int mod = 1e9+;
int k,x,y,dp[][];
inline int pw(int a,int p){
int res=;
while(p){
if(p&)res=1ll*res*a%mod;
a=1ll*a*a%mod;
p>>=;
}
return res;
}
inline int go(int i,int j){
if(i+j>=k)return dp[i][j]=(i+j+1ll*x*pw(y,mod-)%mod)%mod;
if(dp[i][j]!=-)return dp[i][j];
dp[i][j]=1ll*(1ll*go(i+,j)*x%mod+1ll*go(i,j+i)*y%mod)*pw(x+y,mod-)%mod;
return dp[i][j];
}
int main(){
cin>>k>>x>>y;
memset(dp,-,sizeof(dp));
cout<<go(,);
return ;
}
908D New Year and Arbitrary Arrangement的更多相关文章
- [CodeForces]908D New Year and Arbitrary Arrangement
设状态f[i][j]表示有i个a,j个ab的期望 发现如果i+j>=k的话就再来一个b就行了. #include <iostream> #include <cstdio> ...
- Codeforces 908D New Year and Arbitrary Arrangement(概率DP,边界条件处理)
题目链接 Goodbye 2017 Problem D 题意 一个字符串开始,每次有$\frac{pa}{pa+pb}$的概率在后面加一个a,$\frac{pb}{pa+pb}$的概率在后面加一个 ...
- CF 908D New Year and Arbitrary Arrangement——期望dp
题目:http://codeforces.com/contest/908/problem/D 注意是子序列.加一个a对ab个数无影响:加一个b使ab个数多出它前面的a那么多个.所以状态里记录有多少个a ...
- Solution -「CF 908D」New Year&Arbitrary Arrangement
\(\mathcal{Description}\) Link. 给定 \(n,p_a,p_b\),初始有一个空串,每次操作有 \(\frac{p_a}{p_a+p_b}\) 的概率在其后添加字 ...
- Codeforces 908 D.New Year and Arbitrary Arrangement (概率&期望DP)
题目链接:New Year and Arbitrary Arrangement 题意: 有一个ab字符串,初始为空. 用Pa/(Pa+Pb)的概率在末尾添加字母a,有 Pb/(Pa+Pb)的概率在末尾 ...
- 【CodeForces】908 D. New Year and Arbitrary Arrangement
[题目]Good Bye 2017 D. New Year and Arbitrary Arrangement [题意]给定正整数k,pa,pb,初始有空字符串,每次有pa/(pa+pb)的可能在字符 ...
- Codeforces New Year and Arbitrary Arrangement
New Year and Arbitrary Arrangement time limit per test2 seconds You are given three integers k, pa a ...
- $CF908D\ New\ Year\ and\ Arbitrary\ Arrangement$ 期望$dp$
正解:期望$dp$ 解题报告: 传送门$QwQ$ 阿关于题目里那个形如$ab$的子序列我说下,,,我我我之前$get$了好久$QAQ$.这里子序列的个数的定义是这样儿的,举个$eg$,$aabb$,就 ...
- Good Bye 2017 D. New Year and Arbitrary Arrangement
看了别人的题解 首先这题是一个dp dp[i][j] i是当前有多少个a j是当前有多少个ab子序列 dp[i][j] = dp[i+1][j]*Pa + dp[i][i+j]*Pb; i,j 时加一 ...
随机推荐
- NoClassDefFoundError: org/apache/juli/logging/LogFactory
将 apache-tomcat-7.0.8\lib 下的 tomcat-util.jar添加到 注:不是 直接在 configure build path 中添加 jar
- 关于FPGA供电
FPGA是一种多电源需求的芯片,主要有3种电源需求: VCCINT:核心工作电压,PCI Express (PCIe) 硬核IP 模块和收发器物理编码子层(PCS) 电源.一般电压都很低,目前常用的F ...
- "==" 与 “equals”
“==”: “==”或等号操作在Java编程语言中是一个二元操作符,用于比较原生类型和对象.(操作符不支持重载overloading) “==”对比两个对象基于内存引用,如果两个对象的引用完全相同(指 ...
- Spring AOP两种实现方式
一. AOP 概念: Spring AOP 即Aspect Oriented Programming(面向切面编程), 实现方式分为两种: 1. 注解(Annotation) 2. 配置(Config ...
- POJ 2674 Linear world(弹性碰撞)
Linear world Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 4426 Accepted: 1006 Desc ...
- 安装scikit-image问题
参考地址: Image Processing Using Python https://code.tutsplus.com/tutorials/image-processing-using-pytho ...
- Oracle查看和修改连接数
1.查询数据库当前进程的连接数: select count(*) from v$process; 2.查看数据库当前会话的连接数: elect count(*) from v$sessio ...
- Python Tuples
1. basic Tuples is a sequence of immutable object. It's a sequence, just like List. However, it cann ...
- 初始mysql语句
操作文件夹(库) 增 : create database db1 charset utf8; 查 : #查看当前创建的数据库 show create database db1; #查看所有的数据库 s ...
- 使用Spring MVC创建 REST API--2
1.提供资源之外的其他内容 @ResponseBody提供了一种很有用的方式,能够将控制器返回的Java对象转换为发送到客户端的资源表述.实际上,将资源表述发送给客户端只是整个过程的一部分.一个好的R ...