A. Vasily the Bear and Triangle
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
Vasily the bear has a favorite rectangle, it has one vertex at point (0, 0), and the opposite vertex at point (x, y). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes.

Vasya also loves triangles, if the triangles have one vertex at point B = (0, 0). That's why today he asks you to find two points A = (x1, y1) and C = (x2, y2), such that the following conditions hold:

the coordinates of points: x1, x2, y1, y2 are integers. Besides, the following inequation holds: x1 < x2;
the triangle formed by point A, B and C is rectangular and isosceles ( is right);
all points of the favorite rectangle are located inside or on the border of triangle ABC;
the area of triangle ABC is as small as possible.
Help the bear, find the required points. It is not so hard to proof that these points are unique.

Input
The first line contains two integers x, y ( - 109 ≤ x, y ≤ 109, x ≠ 0, y ≠ 0).

Output
Print in the single line four integers x1, y1, x2, y2 — the coordinates of the required points.

Sample test(s)
input
10 5
output
0 15 15 0
input
-10 5
output
-15 0 0 15

#include<stdio.h>
int main()
{
__int64 x,y,x1,x2,y1,y2;
scanf("%I64d%I64d",&x,&y);
if (x> && y>)
{
x1=;
y1=x+y;
x2=x+y;
y2=;
}
else if (x< && y>)
{
x1=x-y;
y1=;
x2=;
y2=y-x;
}
else if (x< && y<)
{
x1=(x+y);
y1=;
x2=;
y2=(x+y);
}
else
{
x1=;
y1=y-x;
x2=x-y;
y2=;
}
printf("%I64d %I64d %I64d %I64d\n",x1,y1,x2,y2);
return ;
}

B. Vasily the Bear and Fly
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
One beautiful day Vasily the bear painted 2m circles of the same radius R on a coordinate plane. Circles with numbers from 1 to m had centers at points (2R - R, 0), (4R - R, 0), ..., (2Rm - R, 0), respectively. Circles with numbers from m + 1 to 2m had centers at points (2R - R, 2R), (4R - R, 2R), ..., (2Rm - R, 2R), respectively.

Naturally, the bear painted the circles for a simple experiment with a fly. The experiment continued for m2 days. Each day of the experiment got its own unique number from 0 to m2 - 1, inclusive.

On the day number i the following things happened:

The fly arrived at the coordinate plane at the center of the circle with number  ( is the result of dividing number x by number y, rounded down to an integer).
The fly went along the coordinate plane to the center of the circle number  ( is the remainder after dividing number x by number y). The bear noticed that the fly went from the center of circle v to the center of circle u along the shortest path with all points lying on the border or inside at least one of the 2m circles. After the fly reached the center of circle u, it flew away in an unknown direction.
Help Vasily, count the average distance the fly went along the coordinate plane during each of these m2 days.

Input
The first line contains two integers m, R (1 ≤ m ≤ 105, 1 ≤ R ≤ 10).

Output
In a single line print a single real number — the answer to the problem. The answer will be considered correct if its absolute or relative error doesn't exceed 10 - 6.

Sample test(s)
input
1 1
output
2.0000000000
input
2 2
output
5.4142135624

#include<math.h>
#include<stdio.h>
double dis(int x,double R)
{
if (x==) return *R+sqrt(2.0)*R;
return (*x-)*R+sqrt(8.0)*R;
}
int main()
{
double m,R;
int i;
scanf("%lf%lf",&m,&R);
double tot=m**R;
for (i=;i<m;i++) tot+=dis(i,R)*(m-i)*;
double ave=tot/(m*m*1.0);
printf("%.10lf\n",ave);
return ;
}

CodeForces Round 195 Div2的更多相关文章

  1. Codeforces Round #539 div2

    Codeforces Round #539 div2 abstract I 离散化三连 sort(pos.begin(), pos.end()); pos.erase(unique(pos.begin ...

  2. 【前行】◇第3站◇ Codeforces Round #512 Div2

    [第3站]Codeforces Round #512 Div2 第三题莫名卡半天……一堆细节没处理,改一个发现还有一个……然后就炸了,罚了一啪啦时间 Rating又掉了……但是没什么,比上一次好多了: ...

  3. Codeforces Round#320 Div2 解题报告

    Codeforces Round#320 Div2 先做个标题党,骗骗访问量,结束后再来写咯. codeforces 579A Raising Bacteria codeforces 579B Fin ...

  4. Codeforces Round #564(div2)

    Codeforces Round #564(div2) 本来以为是送分场,结果成了送命场. 菜是原罪 A SB题,上来读不懂题就交WA了一发,代码就不粘了 B 简单构造 很明显,\(n*n\)的矩阵可 ...

  5. Codeforces Round #361 div2

    ProblemA(Codeforces Round 689A): 题意: 给一个手势, 问这个手势是否是唯一. 思路: 暴力, 模拟将这个手势上下左右移动一次看是否还在键盘上即可. 代码: #incl ...

  6. Codeforces Round #626 Div2 D,E

    比赛链接: Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics) D.Present 题意: 给定大 ...

  7. CodeForces Round 192 Div2

    This is the first time I took part in Codeforces Competition.The only felt is that my IQ was contemp ...

  8. Codeforces Round #359 div2

    Problem_A(CodeForces 686A): 题意: \[ 有n个输入, +\space d_i代表冰淇淋数目增加d_i个, -\space d_i表示某个孩纸需要d_i个, 如果你现在手里 ...

  9. Codeforces Round #360 div2

    Problem_A(CodeForces 688A): 题意: 有d天, n个人.如果这n个人同时出现, 那么你就赢不了他们所有的人, 除此之外, 你可以赢他们所有到场的人. 到场人数为0也算赢. 现 ...

随机推荐

  1. 滑动菜单栏(一)开源项目SlidingMenu的使用

    本帖最后由 user1 于 2013-7-16 21:56 编辑 一.SlidingMenu简介相信大家对SlidingMenu都不陌生了,它是一种比较新的设置界面或配置界面的效果,在主界面左滑或者右 ...

  2. 第9章 使用ssh服务管理远程主机。

    章节简述: 学习使用nmtui命令配置网卡参数.手工将多块网卡做绑定.使用nmcli命令查看网卡信息和使用ss命令查看网络及端口状态. 完整演示sshd服务配置方法并详细讲述每个参数的作用,实战基于密 ...

  3. NGUI之UICamera控制触摸,鼠标事件

    http://blog.csdn.net/onerain88/article/details/18963539 . UICamera 功能介绍 主要包括UI事件的监听,分发,覆盖范围为此Camera渲 ...

  4. 【NGUI】grid下面的item的重复利用

    http://blog.csdn.net/u012091672/article/details/21159075解决的问题 使用grid放置item的时候,每次数据可能都不一样,但是每次都删除grid ...

  5. meanshift和camshift

    参考:http://www.cnblogs.com/tornadomeet/archive/2012/03/15/2398769.html 照着这位大神的代码运行了一下,发现meanshift的跟踪效 ...

  6. LBP

    参考:http://www.cnblogs.com/mikewolf2002/p/3438698.html

  7. 秀尔算法:破解RSA加密的“不灭神话”

    RSA加密 VS 秀尔算法 作为RSA加密技术的终结者——“太多运算,无法读取”的秀尔算法(Shor’s algorithm)不是通过暴力破解的方式找到最终密码的,而是利用量子计算的并行性,可以快速分 ...

  8. error: library dfftpack has Fortran sources but no Fortran compiler found解决方法

    用pip install scipy 时提示 error: library dfftpack has Fortran sources but no Fortran compiler found 解决方 ...

  9. lucas定理,组合数学问题

    对于C(n, m) mod p.这里的n,m,p(p为素数)都很大的情况.就不能再用C(n, m) = C(n - 1,m) + C(n - 1, m - 1)的公式递推了. 这里用到Lusac定理 ...

  10. ubuntu 桌面版性能调优

    http://www.howtogeek.com/115797/6-ways-to-speed-up-ubuntu/