hdu 4007 Dave(线性探查+枚举)】的更多相关文章

Problem Description Recently, Dave is boring, so he often walks around. He finds that some places are too crowded, for example, the ground. He couldn't help to think of the disasters happening recently. Crowded place is not safe. He knows there are N…
Dave Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 4095    Accepted Submission(s): 1390 Problem Description Recently, Dave is boring, so he often walks around. He finds that some places are to…
题意:给定正方形的边长 r ,在平面内寻找正方形可以圈住的点的最大的个数. 分析:先对点排序,然后固定一条边,再平移另一条垂直边,得到点的个数,最后比较大小即可. 注意:不包含正方形倾斜的情况! // Time 125ms; Memory 240k #include<iostream> #include<cstdio> #include<algorithm> using namespace std; struct point { int x,y; }; bool ope…
abs 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5778 Description Given a number x, ask positive integer y≥2, that satisfy the following conditions: The absolute value of y - x is minimal To prime factors decomposition of Y, every element factor a…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5358 题意:如题. 解法:观察式子发现,由于log函数的存在,使得这个函数的值域<=34,然后我们枚举这个值域,对于这个值域,我们用双指针O(n)维护值前缀和在这个值域里面的区间,计算即可. #include <bits/stdc++.h> using namespace std; const int maxn = 100005; typedef long long LL; LL l[35]…
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=4587 TWO NODES Time Limit: 24000/12000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 1448    Accepted Submission(s): 441 Problem Description Suppose that G is an undir…
好题~~ 给你n个数和k,求有多少的区间使得区间内部任意两个数的差值小于k,输出符合要求的区间个数,枚举后界~~ 又是一种没见过的方法,太弱了/(ㄒoㄒ)/~~ #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <iostream> #include <queue> #include <algorithm> #…
题意:给一个数列,按如下公式求和. 分析:场上做的时候,傻傻以为是线段树,也没想出题者为啥出log2,就是S(i,j) 的二进制表示的位数.只能说我做题依旧太死板,让求和就按规矩求和,多考虑一下就能发现这个题目应该是另想办法解决的,类似于改代码的题目,直接告诉你C++代码,让你从TLE改成AC,其实真正让你改的是算法,全身都要变. 看了题解,终于明白这道题目的正解算法: 因为S(i,j)的位数在一定范围内是一样的,所以我们可以枚举位数1~35(顶多是2^34),怎么计算(i+j)?继续枚举起点k…
题意: n个物体从高H处以相同角度抛下,有各自的初速度,下面[L1,R1]是敌方坦克的范围,[L2,R2]是友方坦克,问从某个角度抛出,在没有一个炮弹碰到友方坦克的情况下,最多的碰到敌方坦克的炮弹数. 解法: 枚举角度,将pi/2分成1000份,然后枚举,通过方程 v*sin(theta)*t - 1/2*g*t^2 = -H 解出t,然后 x = v*cos(theta)*t算出水平距离,直接统计即可. 代码: #include <iostream> #include <cstdio&…
树形枚举--搜索 题目描述: 给你一棵树,要在一条简单路径上选3个不同的点构成一个集合,问能构成多少个不同的集合. 解法: 枚举所有结点,假设某个结点有n棵子树,每棵子树的结点个数分别为s1,s2,````sn.那么在选中该结点后,剩下的两个结点从子树上选,考虑顺序,则有方案数ans =  s1*(sum(si) - s1) + s2*(sum(si) - s2) + ``` + sn*(sum(si) - sn),化简得ans = sum(si) ^ 2 - sum(si ^2) .实际上,另…