HDU 5200 脑洞题 离线】的更多相关文章

线段树,TLE,各种.唉....我真是笨死了.... 我用的线段树是记录左右区间最长连续棵数的...反正TLE #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int N=50050; struct Q{ int val,index; }Que[N]; int SegT[N*4],L[N*4],R[…
传送门 Trees  Accepts: 156  Submissions: 533  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 65536/65536 K (Java/Others) Problem Description Today CodeFamer is going to cut trees.There are N trees standing in a line. They are numbered from 1 to N…
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABPoAAANFCAIAAABtIwXVAAAgAElEQVR4nOydeVxTV/r/n9ertaJEC4…
N! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 64256    Accepted Submission(s): 18286 Problem Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N!   Input One N in…
How far away ? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 25408    Accepted Submission(s): 10111 Problem Description There are n houses in the village and some bidirectional roads connectin…
Portal Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2027    Accepted Submission(s): 998 Problem Description ZLGG found a magic theory that the bigger banana the bigger banana peel .This impor…
No Pain No Game Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 17    Accepted Submission(s): 5 Problem Description Life is a game,and you lose it,so you suicide.But you can not kill yourself be…
题目链接 题意 将\(x\)拆成\(a_1+a_2+...+\)的形式,且\(a_1\lt a_2\lt...\),使得\(a_1*a_2*...\)取到最大值 思路 大胆猜结论. 首先拆分的形式中肯定不能有\(1\). 于是预处理出前缀和\(a[i]=\sum_{k=2}^{i}k\), 找到\(\geq x\)的最小的\(a[id]\),接下来: 如果\(a[id]==x\),意味着\(2+3+...+id=x\),那么答案就是\(2*3*...*id=factorial(id)\) 否则,…
题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5200 bc(中文):http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=574&pid=1003 题解: 把输入按照高度排序,离线处理出所有高度的答案,每次查询的时候二分查找(upper_bound). #include<iostream> #include<cstring> #inc…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4031 Problem Description Today is the 10th Annual of “September 11 attacks”, the Al Qaeda is about to attack American again. However, American is protected by a high wall this time, which can be treating…
前言: 在写这篇文章之前,首先感谢给我思路以及帮助过我的学长们 以下4篇博客都是学长原创,其中有很多有用的,值得学习的东西,希望能够帮到大家! 1.手把手教你用C++ 写ACM自动刷题神器(冲入HDU首页) 2.[C#] 逆袭--自制日刷千题的AC自动机攻克HDU OJ 3.C#利用POST实现杭电oj的AC自动机器人,AC率高达50%~~ 4.继续Node爬虫 - 百行代码自制自动AC机器人日解千题攻占HDOJ 当初抱着想试试的想法,用过他们的程序,嗯~ o(* ̄▽ ̄*)o. 1.比如那个用C…
Portal Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 931    Accepted Submission(s): 466 Problem Description ZLGG found a magic theory that the bigger banana the bigger banana peel .This import…
题意 有 \(n\) 个区间,第 \(i\) 个区间是 \([l_i,r_i]\) ,它的长度是 \(r_i-l_i\) . 有 \(q\) 个询问,每个询问给定 \(L,R,K\) ,询问被 \([L,R]\) 包含的且长度不小于 \(K\) 的区间数量. \(n,q≤500,000\) 题解 想了无数种 \(O((n+q) \log^2 n)\) 的做法啊TAT 后来看了 这份代码 后恍然大悟 . 这题一个很显然的想法是离线 qwq 首先离线 \(l ~or~ r\) 似乎不太可行 , 因为…
http://acm.hdu.edu.cn/showproblem.php?pid=5326 一道水题,题目大意是在公司里,给出n个员工和目标人数m,然后下面的n-1行是表示员工a管理b,问在这些员工中有多少管理员工的人数是k 起初想的是并查集,后来发现没那么简单,因为两者之间的关系有方向的,a管理b是单向的从b指到a,所以并查集的一个集合里包含了很多种关系 还需要用一个二维数组表示关系,它是一环扣一环的从a找到b再从b找到c......因为如果b管理c,a又管理b,那么a也管理c code #…
区间交 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5700 Description 小A有一个含有n个非负整数的数列与m个区间.每个区间可以表示为li,ri. 它想选择其中k个区间, 使得这些区间的交的那些位置所对应的数的和最大. 例如样例中,选择[2,5]与[4,5]两个区间就可以啦. Input 多组测试数据 第一行三个数n,k,m(1≤n≤100000,1≤k≤m≤100000). 接下来一行n个数ai,表示lyk的数列(0≤ai≤10…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5875 Function Time Limit: 7000/3500 MS (Java/Others)Memory Limit: 262144/262144 K (Java/Others) 问题描述 The shorter, the simpler. With this problem, you should be convinced of this truth. You are given an…
1.Robberies 连接 :http://acm.hdu.edu.cn/showproblem.php?pid=2955      背包;第一次做的时候把概率当做背包(放大100000倍化为整数):在此范围内最多能抢多少钱  最脑残的是把总的概率以为是抢N家银行的概率之和- 把状态转移方程写成了f[j]=max{f[j],f[j-q[i].v]+q[i].money}(f[j]表示在概率j之下能抢的大洋);     正确的方程是:f[j]=max(f[j],f[j-q[i].money]*q…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5162 题解:看了半天以为测试用例写错了.这题玩文字游戏.它问的是当前第i名是原数组中的第几个. #include<stdio.h> #include<iostream> #include<string.h> #include <stdlib.h> #include<math.h> #include<algorithm> #include…
BestCoder Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1614    Accepted Submission(s): 566 Problem Description Mr Potato is a coder.Mr Potato is the BestCoder. One night, an amazing…
http://acm.hdu.edu.cn/showproblem.php?pid=4288 開始的时候,果断TLE,做的方法是,线段树上只维护%5==3的坐标,比方1 2 3 4 5 6 7  假设删除第三个数,就将3,6的位置全+1,就是向右偏移以为,可是求和还是非常慢,所以即使10秒,还是TLE... 正确做法: 1.节点内维护sum[0...4]分别代表区间内%5==i的和 2.结点维护点的个数,cnt 3.离散化处理,然后每次插入时,经过的结点cnt+1或-1,叶子节点Sum[0]就是…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=5534 题意:给你n个点,让你加上n-1条边使他变成一棵树,题目首先给你a[1] a[2].....a[n-1]代表度数为多少时的值,然后问你最大值是多少,n-1条边变成一棵树 思路:这个题首先限制了只能用n^2以下的算法,我们看这个题首先给的东西都是与度数有关,我们建造一棵树度数总和肯定是2*(n-1) 我们其实只要把这个度数当作钱,然后购买相应的商品就可以了,但是你可能买相同的边,有些点你就会没买到造…
E - 5 Time Limit:1500MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 5391 Description Tina Town is a friendly place. People there care about each other. Tina has a ball called zball. Zball is magic. It grows…
当太阳的光辉逐渐被月亮遮蔽,世界失去了光明,大地迎来最黑暗的时刻....在这样的时刻,人们却异常兴奋--我们能在有生之年看到500年一遇的世界奇观,那是多么幸福的事儿啊~~ 但网路上总有那么些网站,开始借着民众的好奇心,打着介绍日食的旗号,大肆传播病毒.小t不幸成为受害者之一.小t如此生气,他决定要把世界上所有带病毒的网站都找出来.当然,谁都知道这是不可能的.小t却执意要完成这不能的任务,他说:"子子孙孙无穷匮也!"(愚公后继有人了). 万事开头难,小t收集了好多病毒的特征码,又收集了…
题目大意: 一个数字组成一堆素因子的乘积,如果一个数字的素因子个数(同样的素因子也要多次计数)小于等于P,那么就称这个数是P的幸运数 多次询问1<=x<=n,1<=y<=m,P , 找到多少对gcd(x,y)是P的幸运数 这里k定为k是P的幸运数 这跟之前做的http://www.cnblogs.com/CSU3901130321/p/4902748.html CSU1325的题目很像,但是这里求sum[]要复杂了很多 本来是枚举k,d求sum的,但是每次询问,P都在变,而我们需要…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=4883 TIANKENG’s restaurant Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 566    Accepted Submission(s): 267 Problem Description TIANKENG manages a…
水题 /* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <ctime> #include <iostream> #include <algorithm> #include <queue> #include <set> #include <m…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3357 #include <cstdio> #include <cmath> #include <algorithm> #include <iostream> #include <cstring> #include <queue> #include <vector> #define maxn 250 #define maxe 1…
搜索 hdu1067 哈希 hdu1401 双向搜索 hdu1430 哈希 hdu1667 跌搜+启发式函数 hdu1685 启发式搜索 hdu1813 启发式搜索 hdu1885 状态压缩搜索 hdu2918 哈希 hdu2931 dfs+dfs hdu2977 bfs+dfs hdu3004 车马炮 hdu3085 双向bfs hdu3900 哈希 hdu4012 状态压缩搜索 hdu4634 状态压缩搜索 poj1324 状态压缩 poj2044 状态压缩 poj3131 双向搜索 poj…
Description Data-mining huge data sets can be a painful and long lasting process if we are not aware of tiny patterns existing within those data sets. One reputable company has recently discovered a tiny bug in their hardware video processing solutio…
http://acm.hdu.edu.cn/showproblem.php?pid=5014 从小数開始模拟找方法规律,然后推广,尤其敢猜敢尝试,错了一种思路继续猜-----这是一种非常重要的方法啊 这道题还是从小数開始模拟,我是依据16以内的找的规律 依据 2^k---2^k-1 2^k+1---2^k-2 ... 这样陪下去 当2^k==n的时候, 从2^(k-1)按相同的方法配下去, WA了非常久,是lower_bound用错了 只是没明确为啥  换成upper_bound也能够AC...…