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 时加一 ...
随机推荐
- Unit06: 外部对象概述 、 window 对象 、 document 对象
Unit06: 外部对象概述 . window 对象 . document 对象 小代码演示: <!DOCTYPE html> <html> <head> < ...
- CMapStringToPtr添加与释放
// 创建MapStringToPtr CMapStringToPtr m_prjFiles; CStringList m_fileList; m_fileList.AddTail(_T(" ...
- cf Double Happiness(判断是否为素数且为4k+1型)
2790. Double Happiness time limit per test 3 seconds memory limit per test 128 megabytes input sta ...
- java封装后引用的例子
封装好的文件: 另外一个文件引用封装文件的方法: 来源: https://www.runoob.com/java/java-encapsulation.html
- JAVA代码实现从文件写入东西后有读出来=========FileInputStream
总结: 这个原理是,先把for循环里的数从程序读到文件里,然后把文件把内容读到程序里 package com.a.b; import java.io.FileInputStream; import j ...
- UGUI 旋转时钟功能
两种模式: 1.Screen Space-Overlay public void OnDrag(PointerEventData eventData) { Vector2 targetDir = ev ...
- python学习 (三十五) logging
1 demo import logging # log level: # DEBUG # INFO # Warning # Error # CRITICAL logging.basicConfig( ...
- js获取页面名称和路径参数
// 取当前页面名称(不带后缀名)function getPageName1(){ var a = location.href; var b = a.split("/" ...
- 【UVA】10391 Compound Words(STL map)
题目 题目 分析 自认已经很简洁了,虽说牺牲了一些效率 代码 #include <bits/stdc++.h> using namespace std; set <s ...
- Django 模型层(2)
多表操作: 创建模型: 作者模型:把作者的详情放到详情表,包含生日,手机号,家庭住址等信息.作者详情模型和作者模型之间是一对一的关系(one-to-one) 出版商模型:出版商有名称,所在城市以及em ...