PAT-1148(Werewolf )思维+数学问题】的更多相关文章

1148 Werewolf - Simple Version (20 分)   Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose that in a game, player #1 said: "Player #2 is a werewolf."; player #2 said: "…
1148 Werewolf - Simple Version (20 分) Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose that in a game, player #1 said: "Player #2 is a werewolf."; player #2 said: "P…
题目链接:1148 Werewolf - Simple Version (20 point(s)) Description Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose that in a game, player #1 said: "Player #2 is a werewolf.";…
Codeforces 1178D (思维+数学) 题面 给出正整数n(不一定是质数),构造一个边数为质数的无向连通图(无自环重边),且图的每个节点的度数为质数 分析 我们先构造一个环,每个点的度数都是2.但由于n不一定是质数,我们还需要再加k条边.然后对于\(i \in [1,k]\),我们加边(i,i+n/2).当\(k\leq \frac{n}{2}\)的时候,只会把一些点的度数由2变成3,否则会出现重边问题.假设新图的边数为m,那\(m \in [n,n+\frac{n}{2}]\),如果…
Werewolf PAT-1148 题目的要点是不管n规模多大,始终只有两个狼人 说谎的是一个狼人和一个好人 紧紧抓住这两点进行实现和分析 #include <iostream> #include <vector> #include <cmath> using namespace std; int main() { int n; cin >> n; vector<int> v(n+1); for (int i = 1; i <= n; i+…
题目:戳这里 题意:鼠标点击n下,第i次点击成功的概率为p[i],连续点击成功x次可以获得x^m分,求n次点击总分数的数学期望. 解题思路:数学期望的题很多都需要转化思维,求某一个单独状态对整体答案的贡献.这主要是利用了期望的可加性. 即:E(X+Y)=E(X)+E(Y); 比如在这题中,第2到3次连续点击成功,则意味着状态为0110....,后面的(...)所有情况概率和为1,也就是说影响第2到3次点击成功的因素只有前四次点击. 这样我们就可以预处理出所有段对答案的贡献,最后遍历一遍求和即可.…
Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose that in a game, player #1 said: "Player #2 is a werewolf."; player #2 said: "Player #3 is a human."; player #3…
Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose that in a game, player #1 said: "Player #2 is a werewolf."; player #2 said: "Player #3 is a human."; player #3…
D. Soldier and Number Game time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the…
题目:戳这里 思路来源:视频讲解 题意:有n个箱子按1...n标号,每个箱子有大小为di的钻石概率为pi,我们初始有个大小为0的钻石,从1到n按顺序打开箱子,遇到比手中大的箱子就换,求交换次数的数学期望. 解题思路:这题跟上题[点这里]很像,都是找到一个子状态,利用数学期望的可加性,处理求和即可.这里的子状态为每一次交换的状态,即 前j个比i大的概率积用树状数组维护. 附ac代码: 1 #include <cstdio> 2 #include <cstdlib> 3 #includ…