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 时加一 ...
随机推荐
- 搭建基于hyperledger fabric的联盟社区(二) --环境配置
接下来讲一下在本地测试区块链网络的过程.我要部署的是2peer+1orderer架构,所以需要准备三台虚拟机,为了方便起见可以先把一台配置好,然后复制出剩余两台即可.搭建虚拟机我用的是virtualb ...
- 常见企业IT支撑【3、SVN代码版本控制系统】
代码版本控制系统有人喜欢用SVN,有人喜欢用GIT 1.环境 os:centos7 apache:2.4.6 python:2.7 --自带 submin2:2.2.1 2.安装ap ...
- python 面向对象(其他相关)
python 面向对象(其他相关): (思维导图 ↑↑↑↑↑↑) 一.issubclass(obj,cls) 检查obj是否是类cls的对象 class Base(object): pass c ...
- Type-C潮流下 如何衡量一款数据线好坏?
不少新一代手机开始支持Type-C接口,比如乐视.PPTV.努比亚Z11.小米4C和三星Note7等.和普通Micro USB相比,Type-C数据线因为正反插的关系对品质要求更高,不然随时有短路烧毁 ...
- sqlserver并发处理,锁和事务
本文系转载,谢谢:http://www.cnblogs.com/cxd4321/archive/2008/12/10/1351792.html 另外这个也不错 http://www.cnb ...
- Oracle函数日期转换成秒(时间戳)
SELECT TO_NUMBER(TO_DATE('2015-01-01 05:00:00', 'YYYY-MM-DD HH24:MI:SS') - TO_DATE( * * FROM DUAL; 秒 ...
- python学习笔记(十二):发送邮件
我们在开发程序的时候,有时候需要开发一些自动化的任务,执行完之后,将结果自动的发送一份邮件,python发送邮件使用smtplib模块,是一个标准包,直接import导入使用即可,代码如下: impo ...
- Julia - 分数
在 Julia 中,使用“//”运算符构造分数 julia> 1 // 2 1//2 julia> - 1 // 2 -1//2 分数会自动进行约分 julia> 2 // 4 1/ ...
- 解决 service iptables start 无法启动的问题
解决方式: iptables -F // 初始化iptables. service iptables save // 保存 service iptables restart // 重启
- [z]计算机架构中Cache的原理、设计及实现
前言 虽然CPU主频的提升会带动系统性能的改善,但系统性能的提高不仅仅取决于CPU,还与系统架构.指令结构.信息在各个部件之间的传送速度及存储部件的存取速度等因素有关,特别是与CPU/内存之间的存取速 ...