hdu 5626 Clarke and points 最大曼哈顿距离
来源:互联网 发布:淘宝女装店铺top排行榜 编辑:程序博客网 时间:2024/05/17 22:43
题目:点击打开链接
题意:给n(<=10^6)个点,求两点的最远曼哈顿距离。
分析:这题和poj2926那题一样。
#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<algorithm>#include<cmath>#include<vector>#include<queue>#include<map>using namespace std;typedef long long ll;const int N=1000000+5;#define INF 20000000000;long long seed;int n;inline long long rand(long long l, long long r) {static long long mo=1e9+7, g=78125;return l+((seed*=g)%=mo)%(r-l+1);}ll f[N][2];int main(){ // freopen("f.txt","r",stdin); ios_base::sync_with_stdio(0); int T; scanf("%d",&T); while(T--){ cin >> n >> seed; for (int i = 0; i < n; i++) f[i][0] = rand(-1000000000, 1000000000), f[i][1] = rand(-1000000000, 1000000000); long long ans=0; for (int k = 0; k < (1 << 2); k++){ long long a = -2000000000; long long b = 2000000000; for (int i = 0; i < n; i++) { ll temp = 0; for (int j = 0; j < 2; j++) if(k>>j &1)temp+=f[i][j]; else temp-=f[i][j]; a = max(a, temp); b = min(b, temp); } ans = max(ans, a - b); } cout<<ans<<endl; } return 0;}
0 0
- hdu 5626 Clarke and points 最大曼哈顿距离
- HDU 5626 Clarke and points(最大曼哈顿距离)
- hdoj 5626 Clarke and points (曼哈顿距离)
- HDU 5626 Clarke and points 求平面最远哈曼顿距离
- HDU 5626 Clarke and points
- HDU 5626 Clarke and points
- HDU 5626 Clarke and points
- hdu 5626 Clarke and points
- HDU Clarke and points
- HDU 5626 Clarke and points(二进制枚举)
- 杭电hdu 5626 Clarke and points【思维】
- hdu 4666 线段树+最大曼哈顿距离
- hdoj 5626 Clarke and points 【思维】
- HDU5626 Clarke and points
- bestcoder #72Clarke and points
- HDU 5762:曼哈顿距离
- hdoj Clarke and points 5626 (数学&变换)
- 【最大曼哈顿距离】POJ2926 Requirements
- bestcoder #72Clarke and points
- cf#ecr7-D - Optimal Number Permutation-构造+脑洞
- new实例化核心::::
- L1正则化如何导致参数的稀疏性
- ThinkPHP3.12使用PHPMailer发送邮件
- hdu 5626 Clarke and points 最大曼哈顿距离
- rpm常用命令总结
- python编程常用模板总结
- const_cast的用法
- Eclipse中设置作者日期等信息
- 三层
- 每天一个linux命令(18):locate 命令
- VMWare虚拟机网络的三种工作模式
- 服务器端Tomcat启动时一闪而过解决办法