No.1274 Fun Lattice Points
タグ : / 解いたユーザー数 35
作問者 :
PCTprobability
/ テスター :
hotman78
Problem Statement
There is a $2$-dimensional coordinate plane, and a piece is placed at $(1,1)$. On this coordinate plane, $ \frac{1}{(x+y)^{(x+y)}}$ is written on each point whose $x,y$ coordinates are both positive, and $0$ is written on all other lattice points.
You are given integers $A,B$. When the piece is currently at lattice point $(p,q)$, the points it can move to are the following $8$ locations:
$(p+A,q+B),(p+A,q-B),(p-A,q+B),(p-A,q-B),(p+B,q+A),(p+B,q-A),(p-B,q+A),(p-B,q-A)$.
Find the sum of the numbers written on the points that can be reached with $0$ or more moves. It can be proved that this value is finite. 21:44 Since $(p-A,q+B)$ appeared $2$ times, one of them was corrected to $(p-A,q-B)$.
Input
$A$ $B$
- All inputs are integers.
- $-10^{18} \le A,B \le 10^{18}$
Output
Output the sum of the numbers written on the reachable points. Your answer is considered correct if the smaller of the relative error and the absolute error is at most $10^{-6}$.
Sample
Sample 1
Input
3 -6
Output
0.250640178827954352087144934691
In this case, the piece can move $3$ times the distance of a chess knight. That is, when at $(a,b)$, it can move to $(a+3,b+6),(a+3,b-6),(a-3,b+6),(a-3,b-6),(a+6,b+3),(a+6,b-3),(a-6,b+3),(a-6,b-3)$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。