Description It has been ten years since TJU-ACM established. And in this year all the retired TJU-ACMers want to get together to celebrate the tenth anniversary. Because the retired TJU-ACMers may live in different places around the world, it may be…
题目链接 正经解法: 给定n个点的坐标,找一个点,到其他点的曼哈顿距离之和最小.n可以是100000.大概要一个O(nlogn)的算法.算曼哈顿距离可以把x和y分开计算排好序后计算前缀和就可以在O(1)时间内判断一个点到其他点的距离. #include<cstdio> #include<algorithm> using namespace std; #define ll long long #define N 100005 int t,n; ll ans,sum[N],sx[N],…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4311 解题报告:在一个平面上有 n 个点,求一个点到其它的 n 个点的距离之和最小是多少. 首先不得不说一下做这道题囧的事,杭电用的是__int64,我前面定义的时候用的是__int64,然后后面输出结果的时候格式控制符竟然用了%lld,还小卡了一会,唉,大意了啊. 然后感觉这题好巧妙,做法是将 x 与 y的距离分开求,我也是看了学长博客之后才懂的http://www.cnblogs.com/Lyu…
异或操作蒙蔽了我的双眼 以至于没有第一时间想到前缀和与后缀和 水题做的不够多 #include<bits/stdc++.h> #define rep(i,j,k) for(register int i=j;i<=k;i++) #define rrep(i,j,k) for(register int i=j;i>=k;i--) using namespace std; typedef long long ll; const int maxn = 1e5+11; ll xxor[max…
Taking Bus Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1275 Accepted Submission(s): 420 Problem Description Bestland has a very long road and there are n bus station along the road, whic…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=4311 Meeting point-1 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3426 Accepted Submission(s): 1131 Problem Description It has been ten years s…
CRB and Tree Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 2112 Accepted Submission(s): 635 Problem Description CRB has a tree, whose vertices are labeled by 1, 2, …, N. They are connected…
题目: http://acm.hdu.edu.cn/showproblem.php?pid=4312 Meeting point-2 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1231 Accepted Submission(s): 691 Problem Description It has been ten years s…
http://acm.hdu.edu.cn/showproblem.php?pid=6186 题意:给出n个数,共有n次询问,每次询问给出一个数p,求除去第p个数后的n-1个数的&.|.^值. 思路:分别计算出&.|.^的前缀和后缀,将前缀和后缀相计算即可. #include<iostream> #include<cstdio> #include<algorithm> using namespace std; ; int n, q; int a[maxn…
Candy Distribution 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5291 Description WY has n kind of candy, number 1-N, The i-th kind of candy has ai. WY would like to give some of the candy to his teammate Ecry and lasten. To be fair, he hopes that…