A9104 | Vasily the Bear and Fly
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $m^{2}$ days. Each day of the experiment got its own unique number from $0$ to $m^{2}-1$ , inclusive.
On the day number $i$ the following things happened:
1. 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).
2. 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 $m^{2}$ days.
Naturally, the bear painted the circles for a simple experiment with a fly. The experiment continued for $m^{2}$ days. Each day of the experiment got its own unique number from $0$ to $m^{2}-1$ , inclusive.
On the day number $i$ the following things happened:
1. 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).
2. 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 $m^{2}$ days.
输入格式
The first line contains two integers $m,R$ ( $1<=m<=10^{5}$ , $1<=R<=10$ ).
输出格式
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}$ .
输入输出样例
输入 #1
1 1
输出 #1
2.0000000000
输入 #2
2 2
输出 #2
5.4142135624

Figure to the second sample
Figure to the second sample
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted