65536K Today is a bad day. Teemo is scolded badly by his teacher because he didn't do his homework.But Teemo is very self-confident, he tells the teacher that the problems in the homework are too simple to solve. So the teacher gets much angrier an…
Teemo likes to drink raspberry juice. He even spent some of his spare time tomake the raspberry juice himself. The way to make the raspberries juice is simple. You just have to press the raspberries through a fine sieve. Unfortunately,today Teemo wa…
65536K Teemo is very interested in convex polygon. There is a convex n-sides polygon, and Teemo connect every two points as diagonal lines, and he want to kown how many segments which be divided into intersections. Teemo ensure that any three diago…
Teemo has a formula and he want to calculate it quickly. The formula is . As the result may be very large, please output the result mod 1000000007. Input Format The input contains several test cases, and the first line is a positive integer T indicat…
A.Teemo's bad day Today is a bad day. Teemo is scolded badly by his teacher because he didn't do his homework.But Teemo is very self-confident, he tells the teacher that the problems in the homework are too simple to solve. So the teacher gets much a…
M. Big brother said the calculation 通过线段树维护. 这个题和杭电的一道题几乎就是一样的题目.HDU5649.DZY Loves Sorting 题意就是一个n的排列,执行Q次操作,每次操作是对某个区间从小到大排序或者从大到小排序.最后只查询一次,输出第k个位置当前的数. 直接按HDU5649这个题写了. 因为只查询一次,而且这是n的全排列,所以直接二分答案,比mid小的赋值为0,大的赋值为1.区间查询判断的时候直接与0和1比较就可以了. 这个题写的简直要骂人…
I题 求 a 数组平方的前缀和和求 a 数组后缀和,遍历一遍即可 AC代码 #include<iostream>#include<cmath>using namespace std;int a[1000005];long long l[1000005], r[1000005];int main(){ int i,n; cin>>n; long long int sum; for(i=0;i<n;i++){ cin>>a[i]; } l[0]=a[0]…
A. Majestic 10 题意:三个数均大于10则输出"triple-double",如果两个数大于10则输出"double-double",如果一个大于10则输出"double",如果没有数大于10则输出"zilch" #include<stdio.h> int main(){ int n,a,b,c; scanf("%d",&n); while(n--){ scanf("…
A Appeal to the Audience 要想使得总和最大,就要使最大值被计算的次数最多.要想某个数被计算的多,就要使得它经过尽量多的节点.于是我们的目标就是找到 k 条从长到短的链,这些链互不重合,且一端是叶子节点.可以通过长链剖分来将这棵树分为 k 条互不相交的长链,然后按照长度分配元素(长度越大,分配给它的元素值越大). #include<bits/stdc++.h> using namespace std; const int N = 1e5+10; const int M =…
今天题目情况如下:A题:线段树+XOR性质.情况:由于写法问题,调试困难,浪费大量时间.B题:(对所有满足i mod p==q,求a[i]之和),无修改,直接上n*sqrt(n)的分块写法.情况:由于250ms的时间限制,浪费大量时间思考新方法,但实际上时限足够.C题:BFS题目,直接SPFA.情况:未花费多少时间,直接写出.D题:方阵行列题,需要智商.情况:未看.E题:给定n个点,需支持询问一个起点到所有n个点的切比雪夫距离以及点的删改.转换坐标+权值线段树.转换坐标貌似很常用.情况:未看.F…
对于深度优先算法,第一个直观的想法是只要是要求输出最短情况的详细步骤的题目基本上都要使用深度优先来解决.比较常见的题目类型比如寻路等,可以结合相关的经典算法进行分析. 常用步骤: 第一道题目:Dungeon Master http://poj.org/problem?id=2251 Input The input consists of a number of dungeons. Each dungeon description starts with a line containing th…
BFS算法与树的层次遍历很像,具有明显的层次性,一般都是使用队列来实现的!!! 常用步骤: 1.设置访问标记int visited[N],要覆盖所有的可能访问数据个数,这里设置成int而不是bool,基于一个考虑,多次循环时不用每次都清空visited,传递进去每次一个数字即可,比如第一次标记为1,判断也采用==1,之后递加即可. 2.设置一个node,用来记录相关参数和当前的步数,比如: struct node { int i; int j; int k; int s;//步数 }; 3.设计…