HDU 5626 Clarke and points
来源:互联网 发布:canon mp236清零软件 编辑:程序博客网 时间:2024/06/07 09:20
问题描述
克拉克是一名精神分裂患者。某一天克拉克变成了一位几何研究学者。 他研究一个有趣的距离,曼哈顿距离。点A(xA,yA)和点B(xB,yB)的曼哈顿距离为∣xA−xB∣+∣yA−yB∣。 现在他有n个这样的点,他需要找出两个点i,j使得曼哈顿距离最大。
输入描述
第一行是一个整数T(1≤T≤5),表示数据组数。 每组数据第一行为两个整数n,seed(2≤n≤1000000,1≤seed≤109),表示点的个数和种子。 n个点的坐标是这样得到的:long long seed;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);}// ...cin >> n >> seed;for (int i = 0; i < n; i++)x[i] = rand(-1000000000, 1000000000),y[i] = rand(-1000000000, 1000000000);
输出描述
对于每组数据输出一行,表示最大的曼哈顿距离。
输入样例
23 2335 332
输出样例
15574399531423870062
统计最大和最小的x+y和x-y就好了
#include<cstdio>#include<cstring>#include<cmath>#include<queue>#include<vector>#include<iostream>#include<algorithm>#include<bitset>#include<functional>using namespace std;typedef unsigned long long ull;typedef long long LL;const int maxn = 1e6 + 10;const int mod = 1e9 + 7;int T, n;LL seed, mina, minb, maxa, maxb;struct point{ LL x, y; bool operator<(const point&a)const { return x == a.x ? x < a.x : y < a.y; }}a[maxn];inline LL rand(long long l, long long r) { static long long mo = 1e9 + 7, g = 78125; return l + ((seed *= g) %= mo) % (r - l + 1);}int main(){ scanf("%d", &T); while (T--) { cin >> n >> seed; for (int i = 0; i < n; i++) { a[i].x = rand(-1000000000, 1000000000); a[i].y = rand(-1000000000, 1000000000); } maxa = mina = a[0].x + a[0].y; maxb = minb = a[0].x - a[0].y; for (int i = 1; i < n; i++) { mina = min(mina, a[i].x + a[i].y); minb = min(minb, a[i].x - a[i].y); maxa = max(maxa, a[i].x + a[i].y); maxb = max(maxb, a[i].x - a[i].y); } cout << max(maxb - minb, maxa - mina) << endl; } return 0;}
0 0
- 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 5626 Clarke and points 最大曼哈顿距离
- HDU 5626 Clarke and points 求平面最远哈曼顿距离
- HDU 5626 Clarke and points(最大曼哈顿距离)
- hdoj 5626 Clarke and points 【思维】
- hdoj 5626 Clarke and points (曼哈顿距离)
- HDU5626 Clarke and points
- bestcoder #72Clarke and points
- hdoj Clarke and points 5626 (数学&变换)
- Clarke and MST HDU
- HDU 5463 Clarke and minecraft
- HDU 5465 Clarke and puzzle
- 现在的问题
- Retrofit 2.0 (v2.0.0-beta4)
- B-Queue on Bus Stop
- MySQL LEFT JOIN
- 人物动画的控制
- HDU 5626 Clarke and points
- 初窥Linux 之 我最常用的20条命令
- poj1014 dfs/背包/类筛法求素数
- 【SPOJ-BTTNS】Buttons【高斯消元】【异或方程组】
- __stdcall,__cdecl,__fastcall的区别
- 剑指Offer:包含min函数的栈(JAVA)
- HDU 5627 Clarke and MST
- node处理get请求
- Mysql表使用全文索引