跳过正文
  1. Posts/

hdoj 5605 || bc #68 div 2 1001 geometry

·1 分钟

题意:geometry Accepts: 324 Submissions: 622 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) 问题描述 在平面直角坐标系上有一个点PP, 他的坐标是(x, y)(x,y). 有一条直线y = kx + by=kx+b经过了PP, 且分别交x, yx,y正半轴于A, BA,B. 求|PA| * |PB|∣PA∣∗∣PB∣的最小值. 输入描述 第一行一个TT, 表示数据组数. 接下来TT行每行两个正整数x,yx,y, 表示PP的坐标.

T=500, 0 < X, Y \leq 10000T=500,0/* *********************************************** Author :111qqz Created Time :2016年01月02日 星期六 18时56分10秒 File Name :code/bc/#68/1001.cpp ************************************************ */

#include #include #include #include #include #include #include #include #include #include #include #include #define fst first #define sec second #define lson l,m,rt«1 #define rson m+1,r,rt«1|1 #define ms(a,x) memset(a,x,sizeof(a)) typedef long long LL; #define pi pair < int ,int > #define MP make_pair

using namespace std; const double eps = 1E-8; const int dx4[4]={1,0,0,-1}; const int dy4[4]={0,-1,1,0}; const int inf = 0x3f3f3f3f; LL x,y; LL b; LL dis(LL a1,LL b1,LL a2,LL b2) {

1LL res = (a1-a2)*(a1-a2)+(b1-b2)*(b1-b2);
2return res;

} int main() {

1#ifndef  ONLINE_JUDGE

// freopen(“code/in.txt”,“r”,stdin); #endif

 1int T;
 2cin>>T;
 3while (T--)
 4{
 5    scanf("%lld %lld",&x,&y);
 6    b = x + y;
 7    LL ans;
 8    ans = dis(x,y,0,b)*dis(x,y,b,0);
 9    cout<<LL(sqrt(ans))<<endl;
10
11}

#ifndef ONLINE_JUDGE fclose(stdin); #endif

1return 0;

}

相关文章

cf 611 B ||codeforces goodbye 2015 B. New Year and Old Property (数学或者数位dp)

http://codeforces.com/contest/611/problem/B 题意:问a到b(1E18),二进制表示中只有一个0的数有多少个。 思路:这么大的数。。。不是有循环节就是math problems. UD:20160318讲道理还有可能是数位dp好不好。。。 我们发现可以很容易得算出1到x的二进制表示中只有一个0 的数有多少个。

codeforces #332 div 2 D. Spongebob and Squares

·2 分钟
http://codeforces.com/contest/599/problem/D 题意:给出总的方格数x,问有多少种不同尺寸的矩形满足题意,输出方案数和长宽(3,5和5,3算两种) 思路:比赛的时候gg了。。其实稍微在纸上推一下。就会得到对于n,m的矩形,一共会有-nnn+3nnm+n+3n*m的方格。数量级是n3。 我们可以实际跑一遍。发现对于x1E18的数量级,n不会超过1442550,1E6,可以搞。

codeforces #333 div 2 D. Lipshitz Sequence

·3 分钟
http://codeforces.com/contest/602/problem/D 题意:见题目描述。 思路:我们很容易发现,l[h]函数其实就是在求区间斜率的最大值。哦不对,是斜率的绝对值的最大值。而且一个显而易见的结论是,斜率最大值一定是由相邻的点得到。画图可以很容易看出。

codeforces 522 A. Vanya and Table

http://codeforces.com/problemset/problem/552/A 题意:一个100*100的网格。然后给n个矩形。每个格子中填上包含这个格子的矩形的个数。最后问所有格子的和。 思路:树状数组搞得…然而..直接求所有矩形面积的和就可以啊喂。。o(n)。。。111qqz你个炒鸡大菜鸡。

codeforces #327 A. Wizards' Duel

·1 分钟
题意:一个长度为l的走廊。两个人站在两端点。互相向对方发射某种魔法。A的魔法速度为p米/秒,B的魔法速度为q米/s,魔法相遇以后会反射。反射会发射人那里会再次发射。问两种魔法第二次相遇的时候距离A的距离。 思路:由于每种魔法的速度保持肯定不变。。所以不管第几次相遇。相遇点都是同一个。。。ans=p*(p+q)/l;