Neighbor House LightOJ - 1047】的更多相关文章

Neighbor House LightOJ - 1047 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int T,TT,n; ][],ans[][]; int main() { int i,j,k; scanf("%d",&T); ;TT<=T;TT++) { scanf("%d",&n); ;i&l…
lightOJ 1047   Neighbor House (DP) 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87730#problem/C 题目: Description The people of Mohammadpur have decided to paint each of their houses red, green, or blue. They've also decided that no two n…
C - C Time Limit:500MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu   Description The people of Mohammadpur have decided to paint each of their houses red, green, or blue. They've also decided that no two neighboring houses will be painte…
题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87730#problem/C 题目: Description The people of Mohammadpur have decided to paint each of their houses red, green, or blue. They've also decided that no two neighboring houses will be painted t…
题目大意: 给你n个房子,要求把房子染成R,G,B三种的一种颜色, 要求相邻的颜色不能一样. dp[第i个房子][第j种颜色]  转移一下就行了.       #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<cmath> #include<queue> #include<vector> #include&l…
The people of Mohammadpur have decided to paint each of their houses red, green, or blue. They've also decided that no two neighboring houses will be painted the same color. The neighbors of house i are houses i-1 and i+1. The first and last houses a…
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1047 题意:见中文题面 思路:该题是求二维的子矩阵的最大值与最小值的差值尽量小.所以可以考虑求出每个子矩阵的最大值和最小值.考虑一维求子段的最小值/最大值的思路.滑动窗口+单调队列. 转换成二维.设minNum[i][j]表示右下角为(i,j)的子矩阵的最小值.先对矩阵每一行用一维的做法求出每一行的子段的最小值,然后同样的方法求列的最值.注意在求列的子段最小值时比较的元素不是原矩阵的元素…
http://lightoj.com/volume_showproblem.php?problem=1422 做的第一道区间DP的题目,试水. 参考解题报告: http://www.cnblogs.com/ziyi--caolu/p/3236035.html http://blog.csdn.net/hcbbt/article/details/15478095 dp[i][j]为第i天到第j天要穿的最少衣服,考虑第i天,如果后面的[i+1, j]天的衣服不要管,那么dp[i][j] = dp[i…
题目链接:http://lightoj.com/volume_showproblem.php?problem=1298 题意:给你两个数 n, p,表示一个数是由前 k 个素数组成的,共有 n 个素数,然后求这样的所有的数的欧拉和: 例如 n = 3, p=2; 前两个素数是2,3, 然后因为n=3,所以要再选一个素数组成一个数,有两种选择2*3*2=12 和 2*3*3=18 结果就是Φ(12)+Φ(18) = 10; 我们可以用dp[i][j] 表示前 j 个素数中选择 i 个的结果,Φ[n…
1047: 小A的计算器 时间限制: 1 Sec  内存限制: 128 MB提交: 124  解决: 105[提交][状态][讨论版] 题目描述 以往的操作系统内部的数据表示都是二进制方式,小A新写了一个操作系统,系统内部的数据表示为26进制,其中0-25分别由a-z表示.现在小A要在这个操作系统上实现一个计算器,这个计算器要能实现26进制数的加法运算.你能帮小A实现这个计算器吗? 输入 输入的第一行包括一个整数N(1<=N<=100).接下来的N行每行包括两个26进制数x和y,它们之间用空格…