06 2014 档案

摘要:2014-06-2317:58:28题意&思路:根据给出的实际天平问题构建二叉树(好吧,只能说偏实际)。思路就是以每个天平的支点构建结构体,参数有wl,dl,wr,dr,左右指针,这样便可以完全描述一个天平了。(第二个版本摘自小白书第二版,非常精简) 1 #include 2 #include ... 阅读全文
posted @ 2014-06-23 18:00 Naturain 阅读(150) 评论(0) 推荐(0)
摘要:2014-06-2115:00:43题意&思路:模拟运算表达式的计算,其中表达式包含空格,前自增(减),后自增(减)。这题是小白书推荐的二叉树题目。。。(但是没搞懂怎样建树,应该是根据中序和结束节点信息条件建树,但是不怎么会,咳咳,用栈模拟了一下) 1 #include 2 #include 3... 阅读全文
posted @ 2014-06-21 15:03 Naturain 阅读(178) 评论(0) 推荐(0)
摘要:2014-06-2023:57:57题意&思路:非常典型的仅根据先序遍历以及结束节点特点,建立二叉树,然后遍历搜索。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 str... 阅读全文
posted @ 2014-06-20 23:58 Naturain 阅读(133) 评论(0) 推荐(0)
摘要:2014-06-2017:14:17题意&思路:题目很长,简单来说就是模拟一下小球下落。速1A。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 int main(){ 7 int Case = 0,pos,m,... 阅读全文
posted @ 2014-06-20 17:15 Naturain 阅读(116) 评论(0) 推荐(0)
摘要:2014-06-2012:07:33A,hash水过。B的话看到这么小的数据量,必然是暴搜,为了节约时间连剪枝都去了。C,数学公式推导,赛后才A,郁闷(QAQ)。(这场round比较诡异的是,到最后才发现是用小号登的,第一次比赛rank270+让小号rating一下+了159,- -!)A: 1 #... 阅读全文
posted @ 2014-06-20 12:09 Naturain 阅读(137) 评论(0) 推荐(0)
摘要:2014-06-1919:51:42题意&思路:以Lisp语句表达式的形式给出二叉树,再问从根到任意节点路径上点值总和是否等于某个值。有了Uva548的经历,这题敲起来顺手多了,虽然还是花了不少时间 (QAQ!)有趣的是对于 0 () 这种情况,(即空树,要求的值为0),Uva和Poj给出了两种答案... 阅读全文
posted @ 2014-06-19 19:56 Naturain 阅读(169) 评论(0) 推荐(0)
摘要:2014-06-1900:27:02题意&思路:给出一棵二叉树的中序遍历和后序遍历,让你求出从根节点到任意叶节点路径上节点值总合的最小值。思路就是根据两个遍历建树,DFS搜索之。非常感谢http://blog.csdn.net/acvcla/article/details/27554837?relo... 阅读全文
posted @ 2014-06-19 00:30 Naturain 阅读(127) 评论(0) 推荐(0)
摘要:2014-06-1723:09:28题意&思路:简单题,开个标记数组。(需要注意的是(i + 7) % 7 - 1,中的i + 7防负操作) 1 #include 2 #include 3 #include 4 using namespace std; 5 6 int main(){ 7 ... 阅读全文
posted @ 2014-06-17 23:11 Naturain 阅读(108) 评论(0) 推荐(0)
摘要:2014-06-1721:50:29题意&思路:有n个队伍,并给出每支队伍的成员号码,对于每个ENQUEUE x 命令, 如果x所在的队伍已经在队列中, 则x排在队列中它的队伍的尾巴,否则排在队列的末尾。每次DEQUEUE命令,把front元素取出并输出来,也就是队中有队了。可以用二维队列来做,我的... 阅读全文
posted @ 2014-06-17 21:55 Naturain 阅读(128) 评论(0) 推荐(0)
摘要:2014-06-1700:10:04做了小白书的线性表专题,有必要总结一下stack , queue(一)Stack: (1)头文件:#include (2)成员函数: stack s; s.push(x) 无返回值,将元素x压栈 s.pop(); 退栈,无返回值 ... 阅读全文
posted @ 2014-06-17 00:19 Naturain 阅读(125) 评论(0) 推荐(0)
摘要:2014-06-1623:48:54题意&思路:逗逗的题目,讲的是俄罗斯套娃,就是一个娃娃里套一个娃娃(小时候玩这货的时候可没想到是Russia的)。。这题是广义的,一个娃娃里可以套多个娃娃,然后给你一列信息,判断能否套成娃(QAQ!萌哭了),思路:开了两个栈,模拟一下就好。(TAT,最后漏掉判s.... 阅读全文
posted @ 2014-06-16 23:54 Naturain 阅读(164) 评论(0) 推荐(0)
摘要:2014-06-1621:27:08题意&思路:给出n个矩阵的row和column,并给出严格运算式,计算计算量。核心:遇到 ')' 运算stack里面的最顶的两个元素,运算完后保存结果(即结果还在stack里) 1 #include 2 #include 3 #include 4 #incl... 阅读全文
posted @ 2014-06-16 21:29 Naturain 阅读(121) 评论(0) 推荐(0)
摘要:2014-06-1618:03:58题意&思路:括号平衡匹配。2个版本 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 int main(){ 8 char s[130],t; 9 ... 阅读全文
posted @ 2014-06-16 18:05 Naturain 阅读(128) 评论(0) 推荐(0)
摘要:2014-06-1616:55:39题意&思路:题意不赘述。思路:一开始的思路比较奇葩。。。后来想想并非最优。而应该从底部向上开始考虑(因为只有与第二堆底部一致的元素不用crawl),严格按照第二堆底部向上的顺序,看看第一堆中有多少个元素的顺序已经符合第二堆,剩下的元素都需要crawl,然而怎么找出... 阅读全文
posted @ 2014-06-16 17:01 Naturain 阅读(173) 评论(0) 推荐(0)
摘要:2014-06-1615:43:57题意&思路:简单环状表模拟。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 int main(){ 7 int n,k,m,pk,pm; 8 int cnt,used... 阅读全文
posted @ 2014-06-16 15:44 Naturain 阅读(113) 评论(0) 推荐(0)
摘要:2014-06-1517:38:11题意&思路:操作描述上并不复杂的表/栈模拟题,但是写起来一定要注意细节!(被逻辑混乱WA了好几次,。TaT!),最后把代码逻辑优化了下,恩恩。 1 #include 2 #include 3 using namespace std; 4 5 struct b... 阅读全文
posted @ 2014-06-15 17:41 Naturain 阅读(110) 评论(0) 推荐(0)
摘要:2014-06-1502:05:36题意&思路:就是简单模拟一下这个处理,由于太困了。。。敲了个普通程序,应该还有很大优化空间。。。。QAQ(被the number of piles == 1时用pile不加s坑了一次) 1 #include 2 #include 3 #include ... 阅读全文
posted @ 2014-06-15 02:08 Naturain 阅读(143) 评论(0) 推荐(0)
摘要:2014-06-1320:24:16题意&思路:主要是用S(ABC) =?= S(ABP) + S(APC) + S(PBC)来判断P是否在三角形ABC内,暴力枚举即可。#include #include #include #include #include using namespace std;... 阅读全文
posted @ 2014-06-13 20:26 Naturain 阅读(183) 评论(0) 推荐(0)
摘要:2014-06-1300:18:59题意&思路: 这个几何题挺有意思,总的思想就是把长a和宽b扩展分别扩展成n,m倍(n为长边的库数,m为宽边的库数),然后便是求对角线对应的角度和长度的问题了。代码精简。#include #include #include using namespace std;c... 阅读全文
posted @ 2014-06-13 00:30 Naturain 阅读(161) 评论(0) 推荐(0)
摘要:2014-06-1223:14:36题意&思路:在等腰三角形内由底向上,堆叠内切圆,算出总周长。(TAT精度判断方法是测样子强行测出来的,谁会想到判断要在while里面,遇到r #include #include using namespace std;const double INF_MIN = ... 阅读全文
posted @ 2014-06-12 23:16 Naturain 阅读(122) 评论(0) 推荐(0)
摘要:2014-06-1221:31:35题意&思路:哎,yy多了浪费时间,静下心来细心推导5分钟便可出。简单题不多说。#include #include #include using namespace std;int main(){ double x1,y1,x2,y2,x3,y3,C,xa,y... 阅读全文
posted @ 2014-06-12 21:33 Naturain 阅读(149) 评论(0) 推荐(0)
摘要:2014-06-1213:13:03题意&思路:gcd,判step,mod最大公约数是否为1,若是则good,否则bad。证明(自己yy的):给出step,mod,令a=lcd(step,mod),把mod拓展开,列出这么几项:(列1)0,mod,2mod,3mod.....,a,再列出(列2)0,... 阅读全文
posted @ 2014-06-12 13:14 Naturain 阅读(185) 评论(0) 推荐(0)
摘要:2014-06-1201:11:10题意&思路:素数拆分,注意一下中间判素数直接输出而防止超时。#include #include #include using namespace std;bool isprime(long long x){ for(long long i = 2; i * ... 阅读全文
posted @ 2014-06-12 01:12 Naturain 阅读(133) 评论(0) 推荐(0)
摘要:#include <stdio.h> int judge(int y){ if((y%100==0&&y%400==0)||(y%100!=0&&y%4==0)) return 1; return 0; } int which_day(int year,int mon,int day){ int i 阅读全文
posted @ 2014-06-12 00:51 Naturain 阅读(380) 评论(0) 推荐(0)
摘要:2014-06-1200:06:41C++文件读入读出: (1)ifstream(fname) 建立读入流,如:ifstream fin("in.txt") (2)ostream(fname) 建立读出流 (3)getline(istream &is , string &str , char ... 阅读全文
posted @ 2014-06-12 00:07 Naturain 阅读(190) 评论(0) 推荐(0)
摘要:2014-06-1123:59:05题意&思路:求n!在b进制下的后缀零个数以及总位数,解决方法在总结中写过。(本来想用Stirling,后来WA了,看来精度不够呢)#include #include #include #include #include #include #include #inc... 阅读全文
posted @ 2014-06-12 00:00 Naturain 阅读(153) 评论(0) 推荐(0)
摘要:2014-06-1121:29:09Q1:阶乘中后缀零的计算显然,n! 前面几项可以写成:1 * 2 * 3 * (2 * 2) * 5 * (2 * 3) * 7 * (2 * 2 * 2) * 9 * (2 * 5).....发现,2 * 5可以使后缀零的个数+1。(而2的个数显然多于5)结论1... 阅读全文
posted @ 2014-06-11 21:36 Naturain 阅读(420) 评论(0) 推荐(0)
摘要:2014-06-1113:59:56题意&思路:简单题不多说。#include #include #include #include using namespace std;int main(){ int s[10005],p[10005],Z,I,M,L,Case = 0; while... 阅读全文
posted @ 2014-06-11 14:00 Naturain 阅读(102) 评论(0) 推荐(0)
摘要:2014-06-11 13:27:30题意&思路:求n阶乘的最右非零位。思路:建表,在每次运算后要进行去零(因为末尾的零对最右非零位产生不了影响),然后要注意的是每次运算后取模,根据 ab mod n = (a mod n)*(b mod n) mod n,当然有可能失真(但这题卡过去了QAQ)#i... 阅读全文
posted @ 2014-06-11 13:30 Naturain 阅读(129) 评论(0) 推荐(0)
摘要:2014-06-1023:50:45题意&思路:直接模拟,处理进制时注意取模#include #include #include using namespace std;int main(){ int Base,d,f,t,c,cnt; while(scanf("%d %d %d",&B... 阅读全文
posted @ 2014-06-10 23:51 Naturain 阅读(111) 评论(0) 推荐(0)
摘要:2014-06-10 22:37:38符号属性 长度属性 基本型 所占位数 取值范围 输入符举例 输出符举例-- -- char 8 -2^7 ~ 2^7-1 %c %c、%d、%usigned -- char 8 -2^7 ~ 2^7-1 %c %c、%d、%uunsigned -- char 8... 阅读全文
posted @ 2014-06-10 22:42 Naturain 阅读(171) 评论(0) 推荐(0)
摘要:2014-06-1022:06:07题意&思路:ai = (ai-1 + ai+1) / 2 - ci 将i从1到n列出n个等式,全部相加,得到:a1 + an = a0 + an+1 - 2(c1+c2+c3+......+cn).关键步骤:将上述式子的n从1开始到n列出你n个式子,(如第二个式子... 阅读全文
posted @ 2014-06-10 22:10 Naturain 阅读(143) 评论(0) 推荐(0)
摘要:2014-06-1017:36:40题意&思路:不说了,数学log没用好- -!#include #include #include using namespace std;int main(){ double t,fac,tf,y,k[30] = {0}; k[2] = 3; f... 阅读全文
posted @ 2014-06-10 17:37 Naturain 阅读(125) 评论(0) 推荐(0)
摘要:2014-06-10 15:56:02题意&思路:分别计算2、3、4维grie / cube / hypercube 中Square、Rectangle(3、4中对应的图形和类推)的个数。首先,可以知道总数为:(n * (n + 1) / 2) ^ k,k为维度,因为某个图形(可能多维)在任何一条坐... 阅读全文
posted @ 2014-06-10 16:31 Naturain 阅读(218) 评论(0) 推荐(0)
摘要:2014-06-1000:28:06题意&思路:简单的多项式除法模拟,写的略丑。。#include #include using namespace std;int main(){ int k,t,r,q[10005],cnt; char c; while(scanf("%d",&... 阅读全文
posted @ 2014-06-10 00:29 Naturain 阅读(118) 评论(0) 推荐(0)
摘要:2014-06-0922:53:58A、B依然水过,,(TAT,A题因为数组开小了WA三次,简直不能再忍!,B一个小错误给hack- -!郁闷的一比)C 在最后才A出:按照蛇形输出,前k-1个都输两个cell,最后一个输出到底。#include #include using namespace st... 阅读全文
posted @ 2014-06-09 23:03 Naturain 阅读(122) 评论(0) 推荐(0)
摘要:2014-06-0820:13:27题意&思路:题意不想赘述,引用一下http://www.cnblogs.com/xiaocai905767378/archive/2011/04/27/2030213.html假设f(a,b)表示它们有多少交点。 结论:f(a,b)=a(a-1)b(b-1)/4 ... 阅读全文
posted @ 2014-06-08 20:16 Naturain 阅读(165) 评论(0) 推荐(0)
摘要:2014-06-0817:26:13题意&思路:算差,推公式,简单题。(TAT,公式题要注意的是判断公式使用范围。。。这题被特判0坑了一次)#include #include #include using namespace std;int main(){ int n,n1,n2; do... 阅读全文
posted @ 2014-06-08 17:27 Naturain 阅读(106) 评论(0) 推荐(0)
摘要:2014-06-0811:53:50题意&思路:题目很绕。。。。简单的说就是给出(N+1)^k , N^k 让你求:1+N+N^2+....+N^(K-1)(转化为:(N^k - 1) / (N -1 ))和(N+1)^k - N^k 。不多说,直接从N枚举,公式搞之。#include #inclu... 阅读全文
posted @ 2014-06-08 11:56 Naturain 阅读(146) 评论(0) 推荐(0)
摘要:2014-06-0722:22:40题意&思路:±1 ± 2 ± 3 ±…± n = k ,找出满足条件的最小n. 令S(n)=1 + 2 + 3 + ... + n.其中一项为x.那么S(n)=1 + 2 + 3 + ...+ x + ... + n.这样结果可能大于等于| k |,等于最好,即一... 阅读全文
posted @ 2014-06-07 22:45 Naturain 阅读(131) 评论(0) 推荐(0)
摘要:2014-06-0718:43:40题意&思路:给出两个cube,每个面涂上颜色,判断这两个cube是否相同(即能否通过旋转获得一样的视觉效果)。直接枚举第二个cube,分别让它的三条轴位于竖直位置,旋转一圈,逐一判断(注意:轴是有方向的,需要上下颠倒一次进行第二次考虑,这里取而代之地把cube一倒... 阅读全文
posted @ 2014-06-07 18:47 Naturain 阅读(224) 评论(0) 推荐(0)
摘要:2014-06-07 18:08:30题意&思路:简单题,没啥好说。(没用long long竟然也AC了,嘿嘿~本来想改的更鲁棒的,懒得敲了。。)#include #include #include using namespace std;int main(){ int n,i,t; w... 阅读全文
posted @ 2014-06-07 18:09 Naturain 阅读(118) 评论(0) 推荐(0)
摘要:2014-06-0717:33:49题意&思路:题目基本上就是让你模仿足球计分排名系统,比较坑爹的点:(1)order 最后那个 rule 要求字典序排列时不考虑大小写(可以考虑为小写排序),还有要注意空格和case间的空行。#include #include #include #include u... 阅读全文
posted @ 2014-06-07 17:36 Naturain 阅读(133) 评论(0) 推荐(0)
摘要:2014-06-05 22:23:48A,B两题直接水过(坑爹的是程序不鲁棒,被hack两次!)C:题意&思路:拆分一串数成k份,要求其中p份各自和为偶数,k-p份各自和为奇数。分析:奇数能转化成偶数(2奇凑1偶),而偶数不能凑成奇数,所以先考虑奇数总数是否大于k-p,再考虑到:如果奇数总数减去看k... 阅读全文
posted @ 2014-06-05 22:38 Naturain 阅读(148) 评论(0) 推荐(0)
摘要:2014-06-04 19:47:37题意&思路:基本的单词检索,排序和标记#include #include #include #include using namespace std;const int maxn = 1000;struct Word{ char s[25]; cha... 阅读全文
posted @ 2014-06-04 21:22 Naturain 阅读(112) 评论(0) 推荐(0)
摘要:2014-06-0401:43:18题意&思路:手动冒泡排序。#include #include using namespace std;int main(){ int Case,n,s[55],cnt; scanf("%d",&Case); while(Case--){ ... 阅读全文
posted @ 2014-06-04 01:44 Naturain 阅读(73) 评论(0) 推荐(0)
摘要:2014-06-0401:40:03题意&思路:变相的冒泡排序,交换的方式比较奇特。思路是逐个找剩余元素中的最大值,并把它转到第一,再转到剩余元素的最后一个,如:51234,把5转到最后;再如15234,把5转到第一,51234再转到最后。#include #include #include usi... 阅读全文
posted @ 2014-06-04 01:42 Naturain 阅读(120) 评论(0) 推荐(0)
摘要:2014-06-0300:03:22题意&思路:计算距离&检索,不多说。#include #include #include using namespace std;const int maxn = 5000;const double INF = 1000000;const double eps =... 阅读全文
posted @ 2014-06-03 00:05 Naturain 阅读(105) 评论(0) 推荐(0)
摘要:2014-06-0300:01:44题意&思路:随便敲个排序上去即可,这里手敲复习了一下快排。#include #include #include #include #include using namespace std;const int maxn = 10000;void quick_sort... 阅读全文
posted @ 2014-06-03 00:03 Naturain 阅读(115) 评论(0) 推荐(0)
摘要:2014-06-0300:00:35题意&思路:简单题。#include #include #include #include using namespace std;struct Country{ char name[80];};Country cou[2005];bool cmp(Coun... 阅读全文
posted @ 2014-06-03 00:01 Naturain 阅读(114) 评论(0) 推荐(0)
摘要:2014-06-0216:46:25题意&思路:简单的单次遍历检索。(以后要求输出空格的时候,直接从样例中取。。。这次傻X地PE两次)#include #include #include #include using namespace std;const int maxn = 1000;int m... 阅读全文
posted @ 2014-06-02 16:48 Naturain 阅读(120) 评论(0) 推荐(0)
摘要:2014-06-0202:03:12总结:A题题意理解有误,耽误了点时间- -!,B题不难,但思路整理花了太多时间,还runtime error了一次,囧!后来就半小时看C了,想来是个简单题,结束后才AA:(写的好挫TAT)#include #include #include using names... 阅读全文
posted @ 2014-06-02 02:12 Naturain 阅读(114) 评论(0) 推荐(0)
摘要:2014-06-0202:02:03题意&思路:判断是否溢出,用double类型即可。#include #include #include #include using namespace std;const int maxn = 1000;const int maxint = 2147483647... 阅读全文
posted @ 2014-06-02 02:03 Naturain 阅读(111) 评论(0) 推荐(0)
摘要:2014-06-0120:00:48题意 & 思路:大数加,不废话。#include #include #include #include using namespace std;const int maxn = 1000;struct bign{ int len,s[maxn + 5]; ... 阅读全文
posted @ 2014-06-01 20:01 Naturain 阅读(154) 评论(0) 推荐(0)
摘要:2014-06-0118:03:30题意 & 思路:大数乘,这里采用的小白书里的bign结构体#include #include #include #include using namespace std;const int maxn = 1000;struct bign{ int len,s... 阅读全文
posted @ 2014-06-01 18:04 Naturain 阅读(119) 评论(0) 推荐(0)
摘要:首先要说明的是ACM题目中涉及的基本是初级高精度,直接模拟手算一般不会超时(也可用java),关于高精度的研究还有很多,介绍一个Huge cal库:http://www.emath.ac.cn/hugecalc/关于字符串,主要增加一些acm入门知识。以分知识点的形式给出:1:scanf %c 有其... 阅读全文
posted @ 2014-06-01 00:52 Naturain 阅读(434) 评论(0) 推荐(0)
摘要:引用:http://blog.csdn.net/chhuach2005/article/details/21168179具体我就不转了,大数乘法一般直接模拟手算,至于分治法、FFT算法、傅里叶高效算法......除非效率有要求、数据很大才会用到。 阅读全文
posted @ 2014-06-01 00:34 Naturain 阅读(128) 评论(0) 推荐(0)
摘要:2014-06-0100:08:41题意 & 思路:循环匹配、替换字符串。呵呵,又是一道典型的字符串处理,scanf %c A之,一开始理解为按单词匹配,后在才发现不是这样(fs : ba g rs : hind the g)。#include #include #include using nam... 阅读全文
posted @ 2014-06-01 00:10 Naturain 阅读(121) 评论(0) 推荐(0)