题目 输入正好是long long的最大, 但是答案超long long 所以用unsigned, 不能用cin cout否则一定超时: 不能用abs(), abs 只用于整数. unsigned   int   0-4294967295   int   2147483648-2147483647 unsigned long 0-4294967295long   2147483648-2147483647long long的最大值:9223372036854775807long long的最小值…
郭式树 Time Limit:2000MS     Memory Limit:128000KB     64bit IO Format:%lld & %llu Submit Status Practice ACdream 1061 Description 郭橐驼,不知始何名.病偻,隆然伏行,有类橐驼者,故乡人号之驼.驼闻之,曰:“甚善.名我固当.”因舍其名,亦自谓橐驼云.其乡曰丰乐乡,在长安西.驼业种树,凡长安豪富人为观游及卖果者,皆争迎取养.视驼所种树,或移徙,无不活:且硕茂,蚤实以蕃.他植者…
A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 135904   Accepted: 42113 Case Time Limit: 2000MS Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type o…
>>点击进入原题测试<< 思路:线段树水题,可以手敲 #include<string> #include<iostream> #include<algorithm> #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 using namespace std; ; ]; void build(int l, int r, int rt) { if (l == r){ cin &g…
题意:      给你一些字符串,然后问你他们中有没有一个串是另一个串的前缀. 思路:       字典树水题,(这种水题如果数据不大(这个题目不知道大不大,题目没说估计不大),hash下也行,把每个串拆成len个串,然后map容器记录下就行了,不想存也 行,最后迭代一下也能出来),回来说字典树,就是最简单的前缀判断应用,我写的结构体里面有3个量,next[], v(出现次数) ,mk (是不是某个字符串的最后一位), 在查找的时候如果我们碰到了已经mk的,那么就直接发现前缀了,某个字符串是当前…
http://wikioi.com/problem/1191/ 太水的线段树了,敲了10分钟就敲完了,但是听说还有一种并查集的做法?不明觉厉. #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostream> #include <algorithm> using namespace std; #define rep(i…
转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Xenia and Bit Operations Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better unders…
这道题模拟一下可以过,但是我们发现线段树也可以安全水过...... 写的线段树只需要滋磁单点修改,区间求max即可 我一开始犯了一个很SB的错误:每次插入修改了t,然后疯狂爆0到怀疑人生... 而且我写的线段树还不明不白的碾了胡雨菲几年前写的. #include <cstdio> #include <algorithm> #include <iostream> using namespace std; ; typedef long long LL; LL mo; LL…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1247 Problem DescriptionA hat’s word is a word in the dictionary that is the concatenation of exactly two other words in the dictionary.You are to find all the hat’s words in a dictionary. InputStandard…
http://poj.org/problem?id=3253 这道题约等于合并果子,但是通过这道题能够看出来哈夫曼树是什么了. #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #include<iostream> #include<queue> using namespace std; #define LL long long ; int n…
http://acm.hdu.edu.cn/showproblem.php?pid=1394 很基础的线段树. 先查询在更新,如果后面的数比前面的数小肯定会查询到前面已经更新过的值,这时候返回的sum就是当前数的逆序数. 这样查询完之后得到初始数列的逆序数,要求得所有序列的最小逆序数,还需要循环一次. 设初始序列abcde中逆序数为k,小于a的个数是t-1那么大于a的个数就是n-t,当把a左移一位,原来比a大的都变成了a的逆序对,即逆序数增加了n-t,但是原来比a小的数都变成了顺序, 因此逆序数…
题目链接 B - 秋实大哥与快餐店 Time Limit:1000MS     Memory Limit:65535KB     64bit IO Format:%lld & %llu Submit Status Practice UESTC 1060 Appoint description:  System Crawler  (2016-04-24) Description 朝为田舍郎,暮登天子堂.秋实大哥从小就怀抱有远大的理想,所以他开了一家快餐店. 秋实大哥根据菜的口感,给每一道菜一个唯一…
Each year, fall in the North Central region is accompanied by the brilliant colors of the leaves on thetrees, followed quickly by the falling leaves accumulating under the trees. If the same thing happenedto binary trees, how large would the piles of…
没什么好说的,标记put表示开关是否开着. #include<cstdio> #include<cstring> #include<algorithm> using namespace std; ; ]; ]; void pushdown(int l,int r,int rt) { if (put[rt]) { put[rt]=; put[rt<<]=!put[rt<<]; put[rt<<|]=!put[rt<<|];…
Description N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电动车从气球a开始到气球b依次给每个气球涂一次颜色.但是N次以后lele已经忘记了第I个气球已经涂过几次颜色了,你能帮他算出每个气球被涂过几次颜色吗?   Input 每个测试实例第一行为一个整数N,(N <= 100000).接下来的N行,每行包括2个整数a b(1 <= a <= b <= N).  当N =…
http://acm.hdu.edu.cn/showproblem.php?pid=1251 建树之后 查询即可. G++提交 ME不知道为什么,c++就对了. #include <iostream> #include <cstdio> #include <cmath> #include <vector> #include <cstring> #include <string> #include <algorithm> #…
I Hate It Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 59558    Accepted Submission(s): 23201 Problem Description 很多学校流行一种比较的习惯.老师们很喜欢询问,从某某到某某当中,分数最高的是多少.这让很多学生很反感. 不管你喜不喜欢,现在需要你做的是,就是按照老师的要…
http://www.lightoj.com/volume_showproblem.php?problem=1065 题意:给出递推式f(0) = a, f(1) = b, f(n) = f(n - 1) +f(n - 2) 求f(n) 思路:给出了递推式就是水题. /** @Date : 2016-12-17-15.54 * @Author : Lweleth (SoungEarlf@gmail.com) * @Link : https://github.com/ * @Version : *…
LSS Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 128000/64000 KB (Java/Others) SubmitStatistic Next Problem Problem Description Time flies, four years passed, colleage is over. When I am about to leave, a xuemei ask me an ACM  problem, but…
A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #include<iostream> #include<algorithm> #include<string.h> #include<stdio.h> #include<math.h> #include<vector> using namespace…
题意:给定 n 条边,判断是不是树. 析:水题,判断是不是树,首先是有没有环,这个可以用并查集来判断,然后就是边数等于顶点数减1. 代码如下: #include <bits/stdc++.h> using namespace std; const int maxn =1000 + 5; int p[maxn]; int Find(int x){ return x == p[x] ? x : p[x] = Find(p[x]); } int main(){ int n, m, x, y; cin…
[pixiv] https://www.pixiv.net/member_illust.php?mode=medium&illust_id=62485671 向大(hei)佬(e)势力学(di)习(tou) Description 给一个长度为n的序列a.1≤a[i]≤n. m组询问,每次询问一个区间[l,r],是否存在一个数在[l,r]中出现的次数大于(r-l+1)/2.如果存在,输出这个数,否则输出0. Input 第一行两个数n,m. 第二行n个数,a[i]. 接下来m行,每行两个数l,r…
1112 - Curious Robin Hood PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 64 MB Robin Hood likes to loot rich people since he helps the poor people with this money. Instead of keeping all the money together he does another trick.…
11.9 线段树 http://acm.hdu.edu.cn/showproblem.php?pid=6315 求逆序对个数 http://acm.hdu.edu.cn/showproblem.php?pid=6318 必赢博弈 http://acm.hdu.edu.cn/showproblem.php?pid=6312 欧拉回路 http://acm.hdu.edu.cn/showproblem.php?pid=6311 好难的构造题目 http://acm.hdu.edu.cn/showpr…
本文含有原创题,涉及版权利益问题,严禁转载,违者追究法律责任 本次是最后一篇免费的考试题解,以后的考试题目以及题解将会以付费的方式阅读,题目质量可以拿本次作为参考 本来半个月前就已经搞得差不多了,然后给一位神犇orz看(神犇orz都是很忙的!),就一直听取意见修修改改呀拖到了半个月之后,不过这也是为了能够做到完美吧 T1-apple-1s 第一题是一道贪心的水题 天数只有两天,不是今天吃就是明天吃,我们将 b[i]=min(x[i],y[i])定为基础开心值,也就是说不论哪天吃都至少可以得到这个…
达神主席树讲解传送门:http://blog.csdn.net/dad3zz/article/details/50638026 2016-02-23:真的是模板题诶,主席树模板水过.今天新校网不好,没有评测,但我立下flag这个代码一定能A.我的同学在自习课上考语文,然而机房党都跑到机房来避难了\(^o^)/~ 2016-02-24:果然A乐~~~,我们机房党又躲过啦数学考试.良心不安啊 #include<cstdio> #include<cstring> #include<…
今天刚学的拓扑排序,大概搞懂后发现这题是赤裸裸的水题. 于是按自己想法敲了一遍,用queue做的,也就是Kahn算法,复杂度o(V+E),调完交上去,WA了... 于是检查了一遍又交了一发,还是WA... 我还以为是用queue的问题,改成stack也WA,然后干脆放弃STL,手敲了队列,还是WA了... 我抓狂了. 感觉没什么问题的,卡了我一个多小时.最后用样例0 1测试,发现是在输入的循环判断时出错了,他要求两个都为0时结束,我只要有一个为0就结束了... 坑爹,血的教训... 然后我把之前…
第一次topcoder,以前老感觉没有资格去做tc,cf什么的,现在已经慢慢接触了. 感觉还可以,还是有让我们这些蒻菜安慰的水题. tc的确很好玩,用客户端比赛,还有各种规则,而且还是只编写一个类提交上去,最后还能cha别人(虽然我还没cha过),具体规则看大神写的这篇文章. 好吧,我的第一次TC的SRM就只刷出了第一道250P的水题,题目字体太小了,看题目看了老半天,然后编写完调试出来,还花了挺长时间去把程序改成类,在客户端上compile,蛋疼的是类的后面的分号忘记写找了好长时间.....…
后天考试,今天做题,我真佩服自己... 这次又只A俩水题... orz各路神犇... 话说这次模拟题挺多... 半个多小时把前面俩水题做完,然后卡C,和往常一样,题目看懂做不出来... A: 算是模拟吧,反正看懂题目后很可耻的生硬水果,没被hack我觉得非常开心... 由于要求两个人至少一个没跳过,画图后发现很偷懒的方法. 虽然跟样例不同,但过了... #include <cstdio> int main() { int n, m; scanf("%d%d", &n…
/* poj1873 The Fortified Forest 凸包+枚举 水题 用小树林的木头给小树林围一个围墙 每棵树都有价值 求消耗价值最低的做法,输出被砍伐的树的编号和剩余的木料 若砍伐价值相同,则取砍伐数小的方案. */ #include<stdio.h> #include<math.h> #include <algorithm> #include <vector> using namespace std; const double eps = 1…