CodeForces 3 67E (109 + 7). Two ways are considered distinct if there is such j(1 ≤ j ≤ n), that the j-th intervals in two corresponding sequences are not equal. (109 + 7);;][MAX][MAX]; {          )     {         memset(dp,,         dp[][][]=;       …
C. Iahub and Permutations time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Iahub is so happy about inventing bubble sort graphs that he's staying all day long at the office and writing permu…
题目描述 求有多少种长度为 n 的序列 A,满足以下条件: 1 ~ n 这 n 个数在序列中各出现了一次 若第 i 个数 A[i] 的值为 i,则称 i 是稳定的.序列恰好有 m 个数是稳定的 满足条件的序列可能很多,序列数对 10^9+7 取模. 输入 第一行一个数 T,表示有 T 组数据. 接下来 T 行,每行两个整数 n.m. T=500000,n≤1000000,m≤1000000 输出 输出 T 行,每行一个数,表示求出的序列数 样例输入 5 1 0 1 1 5 2 100 50 10…
[Codeforces 865C]Gotta Go Fast(期望dp+二分答案) 题面 一个游戏一共有n个关卡,对于第i关,用a[i]时间通过的概率为p[i],用b[i]通过的时间为1-p[i],每通过一关后可以选择继续下一关或者时间清0并从第一关开始,先要求通过所有关卡的时间和不能超过R才算彻底通关,问直到彻底通关位置的游戏时间的期望值为多少 分析 二分从头开始通关的用时期望mid 设\(dp[i][j]\)表示通前i关,当前时间为j的期望,倒推期望. 若超时重新开始,则\(dp[i][j]…
[CodeForces - 1225E]Rock Is Push [dp][前缀和] 标签:题解 codeforces题解 dp 前缀和 题目描述 Time limit 2000 ms Memory limit 524288 kB Source Technocup 2020 - Elimination Round 2 Tags binary search dp *2200 Site https://codeforces.com/problemset/problem/1225/E 题面 Examp…
[Codeforces 553E]Kyoya and Train(期望DP+Floyd+分治FFT) 题面 给出一个\(n\)个点\(m\)条边的有向图(可能有环),走每条边需要支付一个价格\(c_i\),需要的时间为\([1,T]\)中随机的整数,时间为\(j\)的概率为\(p_{i,j}\).从\(1\)出发走到\(n\),如果到\(n\)的时间超过\(T\),就需要再支付\(X\).找出一条路径,使得支付钱数的期望值最小.输出最小期望. \(n \leq 50,m \leq 100,T \…
Sereja is interested in intervals of numbers, so he has prepared a problem about intervals for you. An interval of numbers is a pair of integers [l, r] (1 ≤ l ≤ r ≤ m). Interval [l1, r1] belongs to interval [l2, r2] if the following condition is met:…
Intervals 题目连接: http://codeforces.com/gym/100231/attachments Description Start with an integer, N0, which is greater than 0. Let N1 be the number of ones in the binary representation of N0. So, if N0 = 27, N1 = 4. For all i > 0, let Ni be the number…
题意读了好久才读懂....不知道怎么翻译好~~请自便~~~ http://codeforces.com/problemset/problem/425/C 看懂之后纠结好久...不会做...仍然是看题解看代码才懂的... dp[i][j]表示A数组前i个数,第一个操作做j次的B数组的最小下标.代码里把第一维给压掉了. 复杂度,n*s/e*logn吧... #include <cstdio> #include <cstring> #include <iostream> #i…
Sereja has a sequence that consists of n positive integers, a1, a2, ..., an. First Sereja took a piece of squared paper and wrote all distinct non-empty non-decreasing subsequences of sequence a. Then for each sequence written on the squared paper, S…