UVA 11174 考虑每个人(t)的所有子女,在全排列中,t可以和他的任意子女交换位置构成新的排列,所以全排列n!/所有人的子女数连乘 即是答案 当然由于有MOD 要求逆. #include <cstdio> #include <cstring> #include <vector> using namespace std; typedef long long ll; const int N = 40005; const ll MOD = 1e9+7; int n,…
主题链接:点击打开链接 题意:白书的P103. 加个虚根就能够了...然后就是一个多重集排列. import java.io.PrintWriter; import java.util.ArrayList; import java.util.Scanner; public class Main { static int N = 40100; ArrayList<Integer>[] G = new ArrayList[N]; static long mod = 1000000007; long…
Problem J Stand in a Line Input: Standard Input Output: Standard Output All the people in the byteland want to stand in a line in such a way that no person stands closer to the front of the line than his father. You are given the information about th…
A. On The Way to Lucky Plaza time limit per test 1.0 s memory limit per test 256 MB input standard input output standard output Alaa is on her last day in Singapore, she wants to buy some presents to her family and friends. Alaa knows that the best p…
矩阵乘法,顾名思义矩阵与矩阵相乘, 两矩阵可相乘的前提:第一个矩阵的行与第二个矩阵的列相等 相乘原则: a b * A B = a*A+b*C a*c+b*D c d C D = c*A+d*C c*A+d*C 上代码 struct matrix { ll a[maxn][maxn]; }; matrix matrix_mul(matrix x,matrix y) { matrix temp; ;i<=n;i++) ;j<=n;j++) { tem…
Luogu T7152 细胞(递推,矩阵乘法,快速幂) Description 小 X 在上完生物课后对细胞的分裂产生了浓厚的兴趣.于是他决定做实验并 观察细胞分裂的规律. 他选取了一种特别的细胞,每天每个该细胞可以分裂出 x − 1 个新的细胞. 小 X 决定第 i 天向培养皿中加入 i 个细胞(在实验开始前培养皿中无细胞). 现在他想知道第 n 天培养皿中总共会有多少个细胞. 由于细胞总数可能很多,你只要告诉他总数对 w 取模的值即可. Input 第一行三个正整数 n, x,w Outpu…
Description Assuming a finite – radius “ball” which is on an N dimension is cut with a “knife” of N-1 dimension. How many pieces will the “ball” be cut into most?However, it’s impossible to understand the following statement without any explanation.L…
UVA 1541 - To Bet or Not To Bet 题目链接 题意:这题题意真是神了- -.看半天,大概是玩一个游戏,開始在位置0.终点在位置m + 1,每次扔一个硬币,正面走一步,反面走两步,走到的步上有4种情况: 1.向前走n步 2.向后走n步 3.停止一回合 4.无影响 问能在t次机会内,走到终点m + 1(假设跃过也算走到了)的概率.大于0.5.等于0.5,小于0.5相应不同输出 思路:题意懂了就好办了.事实上就是递推就能够了dp[i][j]表示第i次机会,落在j步的概率.然…