【Codeforces 711C】Coloring Trees】的更多相关文章

[链接] 我是链接,点我呀:) [题意] 连续相同的数字分为一段 你可以改变其中0为1~m中的某个数字(改变成不同数字需要不同花费) 问你最后如果要求分成恰好k段的话,最少需要多少花费 [题解] dp[i][j][k]前i棵树,分成j段,第j段最后一棵树颜色为m的最小花费 很好转移了,分情况就好 [代码] import java.io.*; import java.util.*; public class Main { static InputReader in; static PrintWri…
题目链接: C. Coloring Trees time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided…
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=2000),问满足[数列长度是k && 数列中每一个元素arr[i]在1~n之间 && 数列中元素可以重复]的数列有多少个?结果对10^9+7取余 解题思路:dp[i][j]表示长度是j,最后一位是i的种数 if(kk%i==0) dp[kk][j+1]+=dp[i][j] #inc…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Amr lives in Lala Land. Lala Land is a very beautiful country that is located on a coordinate line. Lala Land is famous with its apple trees grow…
time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard output Anton is growing a tree in his garden. In case you forgot, the tree is a connected acyclic undirected graph. There are n vertices in the tree, e…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output PolandBall lives in a forest with his family. There are some trees in the forest. Trees are undirected acyclic graphs with k vertices and k - 1 e…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output This is an interactive problem. In the interaction section below you will find the information about flushing the output. The New Year tree of h…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Student Vladislav came to his programming exam completely unprepared as usual. He got a question about some strange algorithm on a graph - somet…
[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q个操作; 有以下两种类型 ①将第i个连通块里面灯取反 ②询问你(x1,y1)(x2,y2)这个矩形区域内灯的权值的和; [题解] 要用到二维的树状数组; 取反操作只要O(1)就能完成; 即先不管它是什么,取反就是了; 然后在询问的时候,直接用二维树状数组累加; 这里的累加可能是减也可能是加; 也可能…
[题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小; [题解] 首先明确n<=2的时候是无解的. n>2之后都有解; 这里设 n2+b2=a2 则有 n2=a2−b2 也即 n2=(a+b)∗(a−b) 这里对n分两类讨论; ① n为奇数 则令 a−b=1 a+b=n2 这样 2∗a=n2+1 因为n是奇数所以右边是个偶数; 得出来的a就是整数了…