CodeForces Round 195 Div2
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的更多相关文章
- Codeforces Round #539 div2
Codeforces Round #539 div2 abstract I 离散化三连 sort(pos.begin(), pos.end()); pos.erase(unique(pos.begin ...
- 【前行】◇第3站◇ Codeforces Round #512 Div2
[第3站]Codeforces Round #512 Div2 第三题莫名卡半天……一堆细节没处理,改一个发现还有一个……然后就炸了,罚了一啪啦时间 Rating又掉了……但是没什么,比上一次好多了: ...
- Codeforces Round#320 Div2 解题报告
Codeforces Round#320 Div2 先做个标题党,骗骗访问量,结束后再来写咯. codeforces 579A Raising Bacteria codeforces 579B Fin ...
- Codeforces Round #564(div2)
Codeforces Round #564(div2) 本来以为是送分场,结果成了送命场. 菜是原罪 A SB题,上来读不懂题就交WA了一发,代码就不粘了 B 简单构造 很明显,\(n*n\)的矩阵可 ...
- Codeforces Round #361 div2
ProblemA(Codeforces Round 689A): 题意: 给一个手势, 问这个手势是否是唯一. 思路: 暴力, 模拟将这个手势上下左右移动一次看是否还在键盘上即可. 代码: #incl ...
- Codeforces Round #626 Div2 D,E
比赛链接: Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics) D.Present 题意: 给定大 ...
- CodeForces Round 192 Div2
This is the first time I took part in Codeforces Competition.The only felt is that my IQ was contemp ...
- Codeforces Round #359 div2
Problem_A(CodeForces 686A): 题意: \[ 有n个输入, +\space d_i代表冰淇淋数目增加d_i个, -\space d_i表示某个孩纸需要d_i个, 如果你现在手里 ...
- Codeforces Round #360 div2
Problem_A(CodeForces 688A): 题意: 有d天, n个人.如果这n个人同时出现, 那么你就赢不了他们所有的人, 除此之外, 你可以赢他们所有到场的人. 到场人数为0也算赢. 现 ...
随机推荐
- HNU 12847 Dwarf Tower(最短路+队列优化)
题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12847 解题报告:有n样物品,编号从1到n第i样物品可以通过金 ...
- [POJ1383]Labyrinth
[POJ1383]Labyrinth 试题描述 The northern part of the Pyramid contains a very large and complicated labyr ...
- spring+hibernate常见异常集合
spring+hibernate出错小结: (1)java.lang.NoClassDefFoundError: org/hibernate/context/CurrentSessionContext ...
- Linux 日志文件utmp、wtmp、lastlog、messages
1.有关当前登录用户的信息记录在文件utmp中:==who命令 2.登录进入和退出纪录在文件wtmp中:==w命令 3.最后一次登录文件可以用lastlog命令察看: 4.messag ...
- CentOS 初始化时的分区
/ ext3 8189 固定大小 空 swap 509 固定大小 /boot ext3 100 固定大小 /home ...
- Telegram
官网:https://www.telegram.org/ GitHub:https://github.com/telegramdesktop/tdesktop
- MPlayer-ww 增加边看边剪切功能
解压到 D:\MPlayer-ww 运行 copy_font.bat 安装字体 LED_font.ttf 双击 MPlayer_ww_openWith.reg 添加右键播放功能 outformat.i ...
- codeforces 486B.OR in Matrix 解题报告
题目链接:http://codeforces.com/problemset/problem/486/B 题目意思:给出一个m行n列的矩阵B(每个元素只由0/1组成),问是否可以利用矩阵B,通过一定的运 ...
- ubuntu命令行相关命令使用心得
一.Ubuntu解压缩zip,tar,tar.gz,tar.bz2 ZIP zip可能是目前使用得最多的文档压缩格式.它最大的优点就是在不同的操作系统平台,比如Linux, Windows以及Mac ...
- 【python】a[::-1]翻转
设有一个元组或者列表 a = (1,2,3,4) b = [1,2,3,4] 则a[::-1]和b[::-1]的含义是将元组或列表的内容翻转 a[::-1] # 结果为(4,3,2,1) b[::-1 ...