hdu 5626 Clarke and points 数学推理
Clarke and points
the coordinate of each point is generated by the followed code.
Input
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);
Output
For each test case, print a line with an integer represented the maximum distance.
Sample Input
2
3 233
5 332
Sample Output
1557439953
1423870062
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string.h>
#include<algorithm>
#include<map>
#include<queue>
#include<vector>
#include<cmath>
#include<stdlib.h>
#include<time.h>
#include<stack>
#include<set>
using namespace std;
#define rep0(i,l,r) for(int i = (l);i < (r);i++)
#define rep1(i,l,r) for(int i = (l);i <= (r);i++)
#define rep_0(i,r,l) for(int i = (r);i > (l);i--)
#define rep_1(i,r,l) for(int i = (r);i >= (l);i--)
#define MS0(a) memset(a,0,sizeof(a))
#define MS1(a) memset(a,-1,sizeof(a))
typedef __int64 ll;
template<typename T>
void read1(T &m)
{
T x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
m = x*f;
}
template<typename T>
void read2(T &a,T &b){read1(a);read1(b);}
template<typename T>
void read3(T &a,T &b,T &c){read1(a);read1(b);read1(c);}
template<typename T>
void out(T a)
{
if(a>) out(a/);
putchar(a%+'');
}
ll n,seed;
inline ll rand(ll l, ll r) {
static ll mo=1e9+, g=;
return l+((seed*=g)%=mo)%(r-l+);
}
const ll inf = 0x3f3f3f3f3f3f3f3fLL;
int main()
{
int T;
read1(T);
while(T--){
read2(n,seed);
ll mn0 = inf,mn1 = -inf,mx0 = inf,mx1 = -inf,x,y,ans;
rep0(i,,n){
x = rand(-, );
y = rand(-, );
ll tmp = x + y,temp = x - y;
mn0 = min(mn0,tmp);mn1 = max(mn1,tmp);
mx0 = min(mx0,temp);mx1 = max(mx1,temp);
}
ans = max(mn1 - mn0,mx1 - mx0);
out(ans);puts("");
}
return ;
}
hdu 5626 Clarke and points 数学推理的更多相关文章
- HDU 5626 Clarke and points 平面两点曼哈顿最远距离
Clarke and points 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5626 Description Clarke is a patie ...
- hdu 5626 Clarke and points
Problem Description Clarke is a patient with multiple personality disorder. One day he turned into a ...
- HDU 5628 Clarke and math——卷积,dp,组合
HDU 5628 Clarke and math 本文属于一个总结了一堆做法的玩意...... 题目 简单的一个式子:给定$n,k,f(i)$,求 然后数据范围不重要,重要的是如何优化这个做法. 这个 ...
- HDU 5628 Clarke and math dp+数学
Clarke and math 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5628 Description Clarke is a patient ...
- CF988 D. Points and Powers of Two【hash/数学推理】
[链接]:CF [题意]:从一堆数中选一个最大子集,使得任意两个数相减的绝对值都是2的幂. [分析]:首先很难的一点,需要想到子集最多只能有三个,四个及以上的子集一定不存在(可以证明).当有三个元素时 ...
- hdu 5563 Clarke and five-pointed star 水题
Clarke and five-pointed star Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/show ...
- hdu 4946 Just a Joke(数学+物理)
链接:http://acm.hdu.edu.cn/showproblem.php?pid=4969 Just a Joke Time Limit: 2000/1000 MS (Java/Others) ...
- hdu 5565 Clarke and baton 二分
Clarke and baton Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...
- hdu 5465 Clarke and puzzle 二维线段树
Clarke and puzzle Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...
随机推荐
- Apache Rewrite 服务器变量
Apache提供给rewirte模块的环境变量大概分成5个类型. 第一部分: HTTP headers 部分参数 参数名称: HTTP_USER_AGENT 样例参考值: Mozilla/5.0 (W ...
- JVMInternals--reference
This article explains the internal architecture of the Java Virtual Machine (JVM). The following dia ...
- Editing and Deleting Data
Editing and Deleting Data In the previous chapter we've come to learn how we can use the zend-form a ...
- if elseif else
1)if,else if需要接判断表达式,只有在满足条件的时候执行而else语句是在前面条件都不满足的时候才能执行(2) 一个if...else if...else语句中可以有多个else if语句, ...
- 第一个js程序
<html><head> <title>Untitled</title> <script >function demo(){ alert ( ...
- IIS7下w3wp.exe进程CPU100%问题解决办法
IIS下经常会出现w3wp.exe进程的CPU使用率达到100%的情况,在IIS7出现之前,要想确定问题所在,可以通过WinDbg来调试分析,但整个过程对技术水平要求非常高,可以参考http:// ...
- gitHub添加公钥
gitHub添加公钥 gitHub是通过SSH公钥连接到现有仓库的 设置SSH Key ssh-keygen -t rsa -C "your_email@example.com"G ...
- A.prototype.b=22和A.b=22的区别
// A.prototype.b=22和A.b=22有什么区别 <script> function A(){ this.b=11; }A.b=22;//A.prototype.b=2 ...
- windows server 2012R2 网络慢的那些事
前段时间公司新采购了一台ibm的服务器,装的是 windows server 2012R2, 在做完项目迁移后,发现项目访问数据库缓慢,于是逐项查找原因,最后终于找到解决办法 以Administrat ...
- Entity Framework 配置
Entity Framework的核心 – EDM(Entity Data Model) EDM概述 实体数据模型,简称EDM,由三个概念组成.概念模型由概念架构定义语言文件 (.csdl)来定义,映 ...