2011年6月4日
摘要: 原来有a个坑,现在要添加b个坑,前后每个坑的间距都要是一样的,环形圈的长度为10000,求最小的坑移动长度原来肯定有一个坑不动,剩下a-1个坑,a+b个坑的平均间距为average,对于这a-1个坑,如果它的坐标x满足:average*j<=x<=average*(j+1),则min(x-average*j,average*(j+1)-x)则为此坑移动距离Sample Inputsample input #12 1sample input #22 3sample input #33 1sample input #410 10Sample Outputsample output #1 阅读全文
posted @ 2011-06-04 11:32 yangyh 阅读(395) 评论(0) 推荐(0) 编辑
摘要: 描述:一个需要 9 10 11三块木板,现在他有9+10+11长度的木板,但是分割L长度的木板费用就是L,因此求怎么分割费用最小算法:构造哈夫曼树,队列中取出最小的两个数放在底层,它们的和入队,如此反复;可以利用优先队列priority_queue优先队列priority_queue默认大的数先出队,因此需要重载小于号Sample Input3858Sample Output34HintHe wants to cut a board of length 21 into pieces of lengths 8, 5, and 8. The original board measures 8+5+ 阅读全文
posted @ 2011-06-04 10:43 yangyh 阅读(487) 评论(0) 推荐(0) 编辑
摘要: 题目:p q r s t是变量N表示非:如NrE表示是否相等:如Ers = r==sA表示或:如Ars = r||sK表示与:如Krs = r&&sC表示推导:Crs= !r || s算法:只有5个变量,枚举0~31,每位分别是p q r s t的值,看每次计算的值是不是true从字符串结尾开始入栈:是变量则入栈是操作符则出栈计算完成后再入栈最后看栈顶就可以了Sample Input ApNp ApNq 0 Sample Output tautology not#include <stack>using namespace std;int main(int argc 阅读全文
posted @ 2011-06-04 10:21 yangyh 阅读(400) 评论(0) 推荐(0) 编辑
摘要: #include "stdafx.h"#include "stdio.h"#include "string.h"class Father{public: name() {printf("father name\n");}; virtual call() {printf("father call\n");}; };class Son: public Father{public: name() {p... 阅读全文
posted @ 2011-06-04 01:06 yangyh 阅读(1948) 评论(0) 推荐(1) 编辑