Divisibility by Eight time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain…
[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 \…
[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 629C Famil Door and Brackets 题目描述: 给出完整的括号序列长度n,现在给出一个序列s长度为m.枚举串p,q,使得p+s+q是合法的括号串,长度为n,问p,q的取值数目. 解题思路: 枚举p的长度,可以直接得到q的长度.因为要满足在任意位置'(' 数目大于 ’)‘ 的数目,所以统计一下s串中 ’(‘ - ')' 的最小数目minx.dp[i][j] 代表 到位置 i 时,满足 '(' - ')' == j 的情况数目.然后枚举p的 j…
A. Flipping Game     time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Iahub got bored, so he invented a game to be played on paper. He writes n integers a1, a2, ..., an. Each of those intege…
E. Ever-Hungry Krakozyabra time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Recently, a wild Krakozyabra appeared at Jelly Castle. It is, truth to be said, always eager to have something for…
http://codeforces.com/gym/100405 D题 题在pdf里 codeforces.com/gym/100405/attachments/download/2331/20132014-acmicpc-northwestern-european-regional-contest-nwerc-13-en.pdf D - Diagrams & TableauxA Young diagram is an arrangement of boxes in rows and colum…
https://codeforces.com/contest/1121/problem/F 题意 给你一个有n(<=5000)个字符的串,有两种压缩字符的方法: 1. 压缩单一字符,代价为a 2. 压缩一个串,条件是这个串是前面整个串的连续子串,代价为b 题解 n<=5000 定义dp[i]为压缩前i个字符的代价,则答案为dp[n] dp[i]=min(dp[i-1]+a,min(dp[j]+b)(即[j+1,i]为[1,j]的子串)) 用字符串哈希处理判定一个串是否为前面的子串 坑点 串ab…
题目链接:http://codeforces.com/contest/598/problem/E E. Chocolate Bar time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have a rectangular chocolate bar consisting of n × m single squares. Y…