Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6979 Accepted Submission(s): 2181 Problem Description In the Dark forest, there is a Fairy kingdom where all the spirits will go together and Celebr…
                                                               B. The Meeting Place Cannot Be Changed The main road in Bytecity is a straight line from south to north. Conveniently, there are coordinates measured in meters from the southernmost build…
Problem Description In the Dark forest, there is a Fairy kingdom where all the spirits will go together and Celebrate the harvest every year. But there is one thing you may not know that they hate walking so much that they would prefer to stay at hom…
题意:给定x轴上有n个点,每一个点都有一个权值,让在x轴上选一个点,求出各点到这个点的距离的三次方乘以权值最小. 析:首先一开始我根本不会三分,也并没有看出来这是一个三分的题目的,学长说这是一个三分的题,我就百度了一下什么是三分算法,一看感觉和二分差不多,当然就是和二分差不多,也是慢慢缩短范围. 这个题也这样,在最左端和最右端不断的三分,直到逼进那个点,刚开始我设置的误差eps是10负8,但是TLE了,我以为是太小,三分数太多,然后我又改成10负6还是TLE,我又失望了,干脆我不用误差了,我让它…
Party All the Time Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4282    Accepted Submission(s): 1355 Problem Description In the Dark forest, there is a Fairy kingdom where all the spirits wil…
题意:n个人,都要去參加活动,每一个人都有所在位置xi和Wi,每一个人没走S km,就会产生S^3*Wi的"不舒适度",求在何位置举办活动才干使全部人的"不舒适度"之和最小,并求最小值. 思路:首先能够得出最后距离之和的表达式最多仅仅有两个极点, 更进一步仅仅有一个极点,否则无最小值. 那么我们就可用三分法或者二分法求解.即对原函数三分或对导数二分就可以. #include<cstdio> #include<cstring> #inclu…
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; int jc[100003]; int p; int ipow(int x, int b) { ll t = 1, w = x;…
http://acm.hdu.edu.cn/showproblem.php?pid=1533 这道题直接用了模板 题意:要构建一个二分图,家对应人,连线的权值就是最短距离,求最小费用 要注意void init(int n) 这个函数一定要写 一开始忘记写这个WA了好几发 还有这个题很容易T掉,赋值建图要简化,一开始构建成网络流那种图一直T #include <stdio.h> #include <string.h> #include <iostream> #includ…
http://acm.hdu.edu.cn/showproblem.php?pid=4280 题意:在最西边的点走到最东边的点最大容量. 思路:ISAP模板题,Dinic过不了. #include <cstdio> #include <algorithm> #include <iostream> #include <cstring> #include <string> #include <cmath> #include <que…
参考iwtwiioi的模板写出来的.上午gty讲的并没有听懂,只好自己慢慢对着模板理解. 在HDU上为什么相同的程序提交有时T有时A!!! 奉上sth神犇的模板(不是这道题): var ch:char; q,g,num:array [0..500001] of longint; st:string; son:array [0..500001,'a'..'z'] of longint; ts:array [0..1000001] of char; l,s,t,n,i,j,m,k,ans,head,…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4717 说明下为啥满足三分: 设y=f(x) (x>0)表示任意两个点的距离随时间x的增长,距离y的变化.则f(x)函数单调性有两种:1.先单减,后单增.2.一直单增. 设y=m(x) (x>0)表示随时间x的增长,所有点的最大距离y的变化.即m(x)是所有点对构成的f(x)图像取最上面的部分.则m(x)的单调性也只有两种可能:1.先单减,后单增.2.一直单增. 这个地方的证明可以这样:假如时刻t1…
本文参考: https://www.cnblogs.com/GerynOhenz/p/8727415.html kuangbin的ACM模板(新) 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4347 Problem Description The course of Software Design and Development Practice is objectionable. ZLC is facing a serious problem…
http://acm.hdu.edu.cn/showproblem.php?pid=5651 题意:生成回文串.输出所有回文串的可能数. 题解:mod除法会损失高位,用逆元来代替除法,模板如下 ac代码: #include<stdio.h> #include<string.h> #include<iostream> #include<string> using namespace std; ; int num[maxn]; //char s[maxn]; t…
http://acm.hdu.edu.cn/showproblem.php?pid=2089 题意:求区间内不包含4和连续62的数的个数. 思路: 简单的数位dp模板题.给大家推荐一个好的讲解博客.http://blog.csdn.net/mosquito_zm/article/details/75226543 #include<iostream> #include<algorithm> #include<cstring> #include<cstdio>…
http://acm.hdu.edu.cn/showproblem.php?pid=2222 题意:给出多个单词,最后再给出一个模式串,求在该模式串中包含了多少个单词. 思路: AC自动机的模板题. #include<iostream> #include<algorithm> #include<cstring> #include<cstdio> #include<vector> #include<stack> #include<…
http://acm.hdu.edu.cn/showproblem.php?pid=3549 刚接触网络流,感觉有点难啊,只好先拿几道基础的模板题来练练手. 最大流的模板题. #include<iostream> #include<cstring> #include<string> #include<algorithm> #include<queue> using namespace std; int n, m, flow; ]; //路径记录…
NPY and shot Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description NPY is going to have a PE test.One of the test subjects is throwing the shot.The height of NPY is H meters.He can throw the shot at t…
http://acm.hdu.edu.cn/showproblem.php?pid=4717 大致题意:给出每一个点的坐标以及每一个点移动的速度和方向. 问在那一时刻点集中最远的距离在全部时刻的最远距离中最小. 比赛时一直以为是计算几何,和线段相交什么的有关.赛后队友说这是道三分,细致想了想确实是三分.试着画绘图发现它是一个凸性函数,存在一个最短距离. 然后三分时间就能够了. #include <stdio.h> #include <iostream> #include <m…
题目链接 第一次写三分 三分的基本模板 int SanFen(int l,int r) //找凸点 { ) { //mid为中点,midmid为四等分点 ; ; if( f(mid) > f(midmid) ) r = midmid; else l = mid; } return f(l) > f(r) ? l : r; } 这道题里面任意两点的距离都可以看作是一个凹函数,对任意t对所有凹函数取最大值构成一个新的凹函数,求新函数的最小值 #include<bits/stdc++.h>…
http://acm.hdu.edu.cn/showproblem.php?pid=1285 #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <algorithm> #include <assert.h> #define IOS ios::sync_with_stdio(false) using namespace st…
http://acm.hdu.edu.cn/showproblem.php?pid=2063 过山车 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 14056    Accepted Submission(s): 6196 Problem Description RPG girls今天和大家一起去游乐场玩,终于可以坐上梦寐以求的过山车…
FFT模板题,求A*B. 用次FFT模板需要注意的是,N应为2的幂次,不然二进制平摊反转置换会出现死循环. 取出结果值时注意精度,要加上eps才能A. #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespace std; typedef long long ll; const double pi = acos(-1.0); const i…
题目大意: 有一个最大是100 * 100 的网格图,上面有 s 个 房子和人,人每移动一个格子花费1的代价,求最小代价让所有的人都进入一个房子.每个房子只能进入一个人. 算法讨论: 注意是KM 和 MCMF算法,我写的是MCMF算法,一开始想的是连10000个点,但是不会连那些大众点之间的边,只会连超级点和普通点之间的边.后来觉得只要连房子点和 人点就可以了.连从人到房子的边,容量是1,花费是他们之间的曼哈顿距离,然后超级源点和超级汇点像上面那样连接,注意连点的时候把他们每个点都具体化一下,就…
我比较快速的想到了三分,但是我是从0到2*pi区间进行三分,并且漏了一种点到边距离的情况,一直WA了好几次 后来画了下图才发现,0到2*pi区间内是有两个极值的,每个半圆存在一个极值 以下是代码 #include <cstdio> #include <cmath> #include <algorithm> #define pi acos(-1.0) using namespace std; typedef struct { double x; double y; }po…
题目描述 如题,给出一个N次函数,保证在范围[l,r]内存在一点x,使得[l,x]上单调增,[x,r]上单调减.试求出x的值. 输入输出格式 输入格式: 第一行一次包含一个正整数N和两个实数l.r,含义如题目描述所示. 第二行包含N+1个实数,从高到低依次表示该N次函数各项的系数. 输出格式: 输出为一行,包含一个实数,即为x的值.四舍五入保留5位小数. 输入输出样例 输入样例#1: 3 -0.9981 0.5 1 -3 -3 1 输出样例#1: -0.41421 说明 时空限制:50ms,12…
http://acm.hdu.edu.cn/showproblem.php?pid=1251 题意:给出一些单词,然后有多次询问,每次输出以该单词为前缀的单词的数量. 思路: 字典树入门题. #include<iostream> #include<cstdio> #include<cstring> using namespace std; ; ; struct Trie { ]; int cnt; //前缀数量 int ends; //单词数量,在本题中其实并没有用到…
Common Subsequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 48378    Accepted Submission(s): 22242 Problem Description A subsequence of a given sequence is the given sequence with some e…
The Moving Points Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 72    Accepted Submission(s): 18 Problem Description There are N points in total. Every point moves in certain direction and cer…
询问有多少个模式串出现在了文本串里面.将模式串插入Trie树中,然后跑一边AC自动机统计一下就哦了. 献上一份模板. #include <cstdio> #include <cstring> #include <queue> #define MAX_NODE 240005 #define MAX_CHILD 26 using namespace std; class AC_Automaton { public: int chd[MAX_NODE][MAX_CHILD];…
大数的位数设置很坑,设成700会越界,设成800会超空间,最后设成了750居然就过了.... #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #define LL long long using namespace std; /* * 完全大数模板 * 输出cin>>a * 输出a.print(…