题目链接: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…
E. Chocolate Bar Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/598/problem/E Description You have a rectangular chocolate bar consisting of n × m single squares. You want to eat exactly k squares, so you may need to break…
https://codeforces.com/contest/1132/problem/F 思维 + 区间dp 题意 给一个长度为n的字符串(<=500),每次选择消去字符,连续相同的字符可以同时消去,问最少需要消去多少次 题解 定义dp[l][r]为区间[l,r]剩下一个字符所需要的最小次数 dp[l][r]=min(dp[l][i]+dp[i+1][r]+x) x为消去剩下两个字符所需要的次数,假如两个字符相同需要x=-1 代码 #include<bits/stdc++.h> #de…
https://codeforces.com/contest/1051/problem/D 题意 一个2*n的矩阵,你可以用黑白格子去填充他,求联通块数目等于k的方案数,答案%998244353. 思路 按列dp,定义状态dp[i][j][k]为前i列,有j个联通块,最后一列为k的方案数 处理出列状态之间的转移(会新产生多少个新的联通块) 注意初始化问题 #include<bits/stdc++.h> #define P 998244353 #define ll long long using…
D. Longest Subsequence 题目连接: http://www.codeforces.com/contest/632/problem/D Description You are given array a with n elements and the number m. Consider some subsequence of a and the value of least common multiple (LCM) of its elements. Denote LCM a…
题目链接:http://codeforces.com/contest/762/problem/D 多多分析状态:这个很明了 #include<bits/stdc++.h> using namespace std; #pragma comment(linker, "/STACK:102400000,102400000") #define ls i<<1 #define rs ls | 1 #define mid ((ll+rr)>>1) #define…
Educational Codeforces Round 39  D. Timetable 令\(dp[i][j]\)表示前\(i\)天逃课了\(j\)节课的情况下,在学校的最少时间 转移就是枚举第\(i\)天逃了\(x\)节课,然后取当天逃\(x\)节课情况下在学校的最小值即可 view code #pragma GCC optimize("O3") #pragma GCC optimize("Ofast,no-stack-protector") #include…
Educational Codeforces Round 63 (Rated for Div. 2) D. Beautiful Array time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given an array aa consisting of nn integers. Beauty of array i…
Educational Codeforces Round 53 E. Segment Sum 题意: 问[L,R]区间内有多少个数满足:其由不超过k种数字构成. 思路: 数位DP裸题,也比较好想.由于没考虑到前导0,卡了很久.但最惨的是,由于每次求和的时候需要用到10的pos次幂,我是用提前算好的10的最高次幂,然后每次除以10往下传参.但我手贱取模了,导致每次除以10之后答案就不同余了,这个NC细节错误卡了我一小时才发现. 代码: #include<iostream> #include<…
[Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file for some programming competition problem. His input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually ge…