现在位置: 首页 > 算法 > 文章
2018年12月22日 算法 ⁄ 共 996字 评论关闭
题目链接 题意: 一个矩阵里有很多格子,每个格子有两种状态,可以放牧和不可以放牧,可以放牧用1表示,否则用0表示,在这块牧场放牛,要求两个相邻的方格不能同时放牛,即牛与牛不能相邻。问有多少种放牛方案(一头牛都不放也是一种方案) state[i] 表示对于一行,保证不相邻的方案 状态:dp[i][ state[j] ]  在状态为state[j]时,到第i行符合条件的可以放牛的方案数 状态转移:dp[i][ state[j] ] =Sigma dp[i-1][state'] (...
阅读全文
2018年12月22日 算法 ⁄ 共 1044字 评论关闭
poj 2342 Anniversary party 没有上司的晚会 Ural大学有N个职员,编号为1~N。他们有从属关系,也就是说他们的关系就像一棵以校长为根的树,父结点就是子结点的直接上司。每个职员有一个快乐指数。现在有个周年庆宴会,要求与会职员的快乐指数最大。但是,没有职员愿和直接上司一起与会。 程序名:party 输入格式: 第一行一个整数N。(1<=N<=6000) 接下来N行,第i+1行表示i号职员的快乐指数Ri。(-128<=Ri<=127) 接...
阅读全文
2018年12月22日 算法 ⁄ 共 1594字 评论关闭
Divisibility Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9483   Accepted: 3302 Description Consider an arbitrary sequence of integers. One can place + or - operators between integers in the sequence, thus deriving different arithmetical expressions that evaluate to different values. Let us, for example, take the sequence: 17, 5, -21, 15. There are eight possible ...
阅读全文
2018年12月22日 算法 ⁄ 共 2771字 评论关闭
A Mini Locomotive Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 2115   Accepted: 1173 Description A train has a locomotive that pulls the train with its many passenger coaches. If the locomotive breaks down, there is no way to pull the train. Therefore, the office of railroads decided to distribute three mini locomotives to each station. A mini locomotive can pull o...
阅读全文
2018年12月22日 算法 ⁄ 共 1621字 评论关闭
http://poj.org/problem?id=2392 题意:有一群牛要上太空。他们计划建一个太空梯-----用一些石头垒。他们有K种不同类型的石头,每一种石头的高度为h_i,数量为c_i,并且由于会受到太空辐射,每一种石头不能超过这种石头的最大建造高度a_i。帮助这群牛建造一个最高的太空梯。 吐槽: 做练习的时候,连需不需要对数据排序都没分析清楚。。。下次再也不把练习安排在上午了,一般我上午状态极差(┬_┬) 这题由于数据较水,可以直...
阅读全文
2018年12月21日 算法 ⁄ 共 849字 评论关闭
多次01背包 每种颜色的衣服的分到一组,费用是洗一件衣服的时间,每组求解出最少时间,再逐组累加起来。 #include <iostream> #include <cstring> using namespace std; const int maxn = 102; const int maxm = 12; struct tt { char clr[11]; int cnt; int sum; int pdt[maxn]; } colors[maxn]; bool f[500005]; int main() { int i, j, k, n, m, ans, mid; int x; char t...
阅读全文
2018年12月21日 算法 ⁄ 共 2296字 评论关闭
                                                                                                                                      Zipper Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 14117   Accepted: 4958 Description Given three strings, you are to determine whether the third string can be formed by combining the characters in the first two strings. The first two...
阅读全文
2018年12月21日 算法 ⁄ 共 1893字 评论关闭
Humble Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 13129    Accepted Submission(s): 5705 Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, ... shows the first 20 humble numbers.  Write a program...
阅读全文
2018年12月21日 算法 ⁄ 共 846字 评论关闭
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1059 经典的DP,不会做啊    (╬ ̄皿 ̄)凸  。。。。。。。。。。。 设dp[j]表示高度差为j时,矮塔的高度。 对于每个块x,只有两种放法,1)放到高塔上          2)放到矮塔上    采用滚动数组,维护两个一维数组就可以了。 Code: #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #define min(a,b) a&l...
阅读全文
2018年12月21日 算法 ⁄ 共 1254字 评论关闭
Light Bulb Time Limit: 1 Second      Memory Limit: 32768 KB Compared to wildleopard's wealthiness, his brother mildleopard is rather poor. His house is narrow and he has only one light bulb in his house. Every night, he is wandering in his incommodious house, thinking of how to earn more money. One day, he found that the length of his shadow was changing from time to time while walking betwe...
阅读全文