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也算赢. 现 ...
随机推荐
- 解决win8下chrome浏览器打开提示没有注册类的方法
今天又把win8装回来了,继续装了个chrome浏览器,但是发现只能从安装的文件打开,从快捷方式或者快速启动栏都会提示没有注册类.找到一种解决的办法是删除注册表中的相关键值,具体如下: 1.打开注册表 ...
- Can't connect to local MySQL Server throught socket '/var/run/mysqld/mysqld.sock'(2)
www.iwangzheng.com 由于之前调整了/etc/mysql/my.cnf试图修复数据库不能存中文的问题,这个问题没解决,以至于数据库连接不上了. tail -f /var/log/mys ...
- [BZOJ1202][HNOI2005]狡猾的商人
[BZOJ1202][HNOI2005]狡猾的商人 试题描述 刁姹接到一个任务,为税务部门调查一位商人的账本,看看账本是不是伪造的.账本上记录了n个月以来的收入情况,其中第i 个月的收入额为Ai(i= ...
- 转:PCL+VS2010环境配置
1.下载 http://www.pointclouds.org/downloads/windows.html出下载PCL完全安装包1.6.0 all-in-one-installer,我的电脑是32位 ...
- MD(d)、MT(d)编译选项的区别
1.编译选项的位置 以VS2005为例,这样子打开: 1) 打开项目的Property Pages对话框 2) 点击左侧C/C++节 3) 点击Code ...
- next_permutation 和 一个不成功的案例
一个失败的案例:(POJ 1009) 题目描述 小翔同学的宿舍WIFI添加了密码,密码每天都会变更.而小翔每天都会给蹭网的同学们提供密码提示.现在请你根据密码提示,编写程序破译密码. 已知密码提示给出 ...
- NYOJ 5 字符串处理 find()函数应用
http://acm.nyist.net/JudgeOnline/problem.php?pid=5 #include<stdio.h> #include<iostream> ...
- css 之盒子模型
display: none inline block float :none right left clear left right both 清除浮动 是清楚它之前的左 ...
- Android读写assets、raw、sdard和工程文件的方法
Android开发离不开对文件的操作,前面的文章“Android简易数据存储之SharedPreferences”和“Android数据存储之SQLite的操作”,分别讲解了简单的数据的存储和数据库数 ...
- Java面向对象的继承
继承也是面向对象的又一重要特性,继承是类于类的一种关系,通俗来说狗属于动物类,那么狗这个类就继承了动物类 java中的继承是单继承的,一个类只能继承与一个父类 子类继承父类之后,子类就拥有了父类的所有 ...