题目:1002 A Corrupt Mayor's Performance Art
题意:有一个长度 n 的序列,初始染色2,有两种操作,P x ,y ,z,区间x---y染色为z,另一种Q x,y,查询区间 x -- y 有几种颜色,并输出,注意会覆盖。
分析:跟POJ 2777一样,不过这个要输出颜色,所以线段树查询的时候顺便把路径存起来打印。代码:
AC代码:
#...
分类:
其他好文 时间:
2014-09-20 20:07:29
阅读次数:
333
??
3-5 学生成绩统计
Time Limit: 1000MS Memory limit: 65536K
题目描述
通过本题目练习可以掌握对象数组的用法,主要是对象数组中数据的输入输出操作。
设计一个学生类Student
它具有私有的数据成员:学号、姓名、数学成绩、英语成绩、计算机成绩;具有公有的成员函数:求三门课总成绩的函数int sum();
求三门课平均成绩...
分类:
其他好文 时间:
2014-09-20 19:50:59
阅读次数:
361
题意:中文题。
思路:和普通数位dp一样,这里转换成二进制,然后记录有几个一,
统计的时候乘起来就好了。
代码:
#include"cstdlib"
#include"cstdio"
#include"cstring"
#include"cmath"
#include"stack"
#include"algorithm"
#include"iostream"
using namespace...
分类:
其他好文 时间:
2014-09-19 17:40:05
阅读次数:
210
1:cin , cout不是语句,而是iostream类的对象而已,这些都是属于控制平台流;流写入缓冲区,缓冲区刷新到设备上显示。 2:endl特殊字符,表示换行且刷新缓冲区 3:换行和空格一样,除了在头文件上以及字符串字面值。 4:对于结束字符是 换行+ctrl+z+换行 5:while和for区...
分类:
其他好文 时间:
2014-09-18 22:04:34
阅读次数:
139
题目:nyoj 1070 诡异的电梯【Ⅰ】
这个题目源自湘潭大学oj 1206 Dormitory's Elevator
是当时比赛的题目,题目都没有读清楚啊、
分析:这其实就是一个简单的一维dp,用dp【i】表示从1层上到第 i 层花费的最小的体力。
因为不能在相邻的楼层停留,所以可以从dp【i-2】转移,但这样不是最优的还要从dp【i-3】转移,因为这样的话就可以到达所...
分类:
其他好文 时间:
2014-09-17 16:58:12
阅读次数:
266
最大子矩阵,(City Game)SEERC 2004,LA 3029
白书上的例题,看了两节课,终于理解了。DP的思想。
扫描的时候维护 up朝上能有多少空格,left 最多朝左走到多少,right 朝右走到多少。
所以只需要扫描一遍即可得出答案 = up*(right-left+1)
我定义left数组的时候跟 iostream 冲突了。
#inclu...
分类:
其他好文 时间:
2014-09-16 12:45:10
阅读次数:
150
LongintegerAdder-大整数相加以字符读取,然后翻转,相加输出。//LongintegerAdder
#include<iostream>
#include<cstdlib>
usingnamespacestd;
voidinput(inta[],intb[],int&size1,int&size2);
voidprocess(inta[],intb[],intc[]);
voidoutput(intc[]);
..
分类:
其他好文 时间:
2014-09-12 15:23:04
阅读次数:
185
Decode-译码//Decode-译码
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cctype>
usingnamespacestd;
voidprocess(stringstr,charch[],intkey);
intmain()
{
stringstr;
charch[100];
cout<<"Inputthecipher:\n";
cin&..
分类:
其他好文 时间:
2014-09-11 15:33:04
阅读次数:
376
FormataSentence-格式化输出句子//FormataSentence
#include<iostream>
#include<cstdlib>
#include<cctype>
#include<cstring>
usingnamespacestd;
voidget_sentence(chara[],int&size);
voidprocess_sentence(chara[],intsize);
intmain()
{
..
分类:
其他好文 时间:
2014-09-10 19:42:41
阅读次数:
221
Countwordsandletters-计算用户输入一行文本中的单词数和每个字母出现次数//Countwordsandletters
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cctype>
usingnamespacestd;
intmain()
{
intwords_count=1;
intchar_count[26]=..
分类:
其他好文 时间:
2014-09-10 19:38:11
阅读次数:
164