当前位置:网站首页>Niuke 2022 summer training session I chiitoitsu solution
Niuke 2022 summer training session I chiitoitsu solution
2022-07-22 15:39:00 【Henan Laoxiang tangkeke】
The main idea of the topic
A person plays mahjong by himself (34 It's a card type , Each of these 4 Zhang ).
Initial pumping 13 card , Then draw one , Ruohu card , End . Otherwise, discard one .
And in this question , The type of Hu card is only 7 A couple , namely 7 For the same card ( Each pair is different ).
Ensure that the number of cards with the same starting hand does not exceed 2 Zhang .
Given the starting hand , Ask for the expected number of rounds of Hu cards .
Topic link
Ideas
It's not hard to find out , We just discard the single card , No matter which one is discarded , It has no effect on the results . So our strategy is : As long as the drawn card cannot be matched with the card in the hand , Then discard this drawn card .
If we still need three pairs of cards, we can play cards ( namely 6 A single card ), Then our task is Draw any three of the six cards from the stack . Then smoke once , The probability of drawing and not drawing is :
6 ∗ 3 r e m a i n , r e m a i n − 6 ∗ 3 r e m a i n \frac{6 * 3}{remain},\frac{remain - 6 * 3}{remain} remain6∗3,remainremain−6∗3
remain Represents the number of cards left in the Library , And each of the six card types has three .
We use expectation dp Methods , Write the equation of state transition , set up f i , j f_{i,j} fi,j It means that we have i i i A single card , There are still... Left in the library at this time j j j card . So suppose we draw a matching card , Then the single card in hand will be subtracted 2( Pair one , Discard one ). And whether we draw matching cards or not , The number of libraries will be subtracted 1. So we can write the state transition equation :
f i , j = 1 + 3 ∗ i j ∗ f i − 2 , j − 1 + j − 3 ∗ i j ∗ f i , j − 1 f_{i,j} = 1+\frac{3*i}{j} * f_{i-2,j-1} + \frac{j - 3*i}{j} * f_{i,j-1} fi,j=1+j3∗i∗fi−2,j−1+jj−3∗i∗fi,j−1
Note that the problem is to use the inverse of multiplication instead .
Code
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const long long mod = 1e9 + 7;
long long qpow(long long a, long long b)
{
long long tmp = 1;
while(b) {
if(b & 1)
tmp = tmp * a % mod;
a = a * a % mod;
b >>= 1;
}
return tmp;
}
long long div(long long a)
{
return qpow(a, mod - 2);
}
long long sum = 34 * 4 - 13;
long long f[15][34 * 4];
int T;
char ch[31];
string s[20];
int main()
{
for(int j = 3; j <= sum; ++j) {
for(int i = 1; i <= 13; ++i) {
if(j < i * 3)
continue;
long long now = 3 * i * div(j) % mod;
if(i == 1)
f[i][j] = (1 + (f[i][j - 1] * (1LL + mod - now))) % mod;
else
f[i][j] = (1 + (f[i][j - 1] * (1LL + mod - now) % mod) + f[i - 2][j - 1] * now % mod) % mod;
}
}
scanf("%d", &T);
for (int test = 1; test <= T; ++test) {
scanf("%s", ch);
for (int i = 0; i < 13; ++i) s[i] = ch[i * 2], s[i] += ch[i * 2 + 1];
sort(s, s + 13);
int duitsu = 0, single = 0;
for (int i = 0; i < 12; ++i) duitsu += (s[i] == s[i + 1]);
single = 13 - duitsu * 2;
printf("Case #%d: %lld\n", test, f[single][sum]);
}
return 0;
}
边栏推荐
- OUU益生菌精耕胃肠健康,获奖天猫国际微生态创新大会
- AI chief architect 11 - "3d+ai" application and expansion in smart Sports
- PLT draw and save the results
- codeforces每日5题(均1500)-第二十二天
- K-means clustering modeling and programming
- Rebound shell carries out suid authorization through ordinary users
- C语言实现在屏幕上打印特定的*星号图案
- Write a maze game with R
- Cloud native ide: the first general and powerful codeless development platform of IVX
- Halcon displays point clouds in TXT file format
猜你喜欢
Ouu probiotics intensive cultivation of gastrointestinal health, award-winning tmall international Micro Ecological Innovation Conference
时序数据库
产业数字化全面加速,智能云网2.0重新定义数字化转型
JS高级 之 ES6 实现继承
牛客2022暑期集训第一场C题 Grab the Seat! 题解
【C语言-文件】数据终于可以出内存,到外面的世界看看了/(ㄒoㄒ)/~~
如何用一手数据可视化获得老板的青睐,抓住数据可视化关键点
还在问用什么来做接口测试?万能Jmeter打造性能测试数据平台
K-means clustering modeling and programming
Bannertext (watermark text)
随机推荐
上传图片到本机iis服务器,结果以网页地址形式返回,可直接访问
vlc报错——“live555 error: no data received in 10s, aborting”
MySQL (28) - transaction related
欢乐的彝族火把节Joyous Torch Festival of the Yi Nationality
Ouu probiotics intensive cultivation of gastrointestinal health, award-winning tmall international Micro Ecological Innovation Conference
用R写一个迷宫小游戏
蒙特卡洛树搜索(MCTS)详解
How to use current probe correctly
df. drop_ Duplicates() explanation + usage
Barcode(条形码)
TDengine学习笔记
Values swxxdp calculation in Res
滑动窗口框架
ES6——模块
优炫数据库上可以搭建Oracle RAC吗?
A Recommendation for interface-based programming
调试VBS visual studio
How to use first-hand data visualization to win the favor of the boss and grasp the key points of data visualization
重载(overload)和重写(override)的区别
Kubernetes basic part learning notes