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 时加一 ...
随机推荐
- linux中日志文件查找,根据关键字,vi命令,awk和wc
参考: http://www.cnblogs.com/ggjucheng/archive/2013/01/13/2856896.html 当时需求:查看系统日志,统计系统的处理时间(从请求进去系统到系 ...
- Linux:数据库服务(Mysql安装及链接、远程链接、genelog)
yum search + 服务:查询服务是否存在: yum remove + 服务:卸载服务: 使用 service 操作服务时,服务的名称后要加上字符 d,如启动:service my ...
- line 1: syntax error: unexpected word (expecting ")")
编译出来的程序在arm平台上运行时,出现下面的错误. / # wpa_supplicant -B -c/etc/wpa_wpa2.conf -iwlan0 /bin/wpa_supplicant: ...
- eclipse使用SSH框架出现There is no Action mapped for namespace [/] and action name [] associated with context path错误
eclipse使用SSH框架出现There is no Action mapped for namespace [/] and action name [] associated with conte ...
- Oracle参数修改是否需要重启等
Oracle参数修改小结Oracle中有些参数是可以在session级别修改,有些则必须在system级别修改,有些参数不需要重启就能马上生效,有些参数必须重启才能生效,那么如何知道这些信息呢?可以从 ...
- PHP中的traits简单理解
Traits可以理解为一组能被不同的类都能调用到的方法集合,但Traits不是类!不能被实例化.先来例子看下语法: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 ...
- bash中常用的快捷键
常用快捷键 ctrl+c 强制终止当前命令 ctrl+l 清屏(clear) ctrl+a 光标移动到命令行行首 ctrl+e 光标移动到命令行行尾 ctrl+u 从光标所在位置删除到行首 ctrl+ ...
- Monkey Test 命令使用
1. 命令使用 Monkey是一个命令列工具 ,可以运行在仿真器里或实际设备中.它向系统发送伪随机的使用者事件流,实现对正在开发的应用程序进行压力测试.Monkey包括许多选项,它们大致分为四大类: ...
- ubuntu安装Theano+cuda
由于学习需要用到GPU加速机器学习算法,需要安装theano+cuda. 开源库的一大问题就是:难安装. 为了搞好这个配置,我是前前后后花了3天,重装了3次ubuntu重装了5次驱动才搞定. 故发此贴 ...
- Mysql 中的伪列用法1
SELECT ( @rowNO := @rowNo + 1 ) AS rowno, A.*FROM ( SELECT * FROM t_user ) a, ( SELECT @rowNO := 0 ) ...