102461: [AtCoder]ABC246 B - Get Closer

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $200$ points

Problem Statement

From the point $(0,0)$ in a two-dimensional plane, let us move the distance of $1$ toward the point $(A, B)$. Find our coordinates after the move.

Here, after moving the distance of $d$ from a point $X$ to a point $Y$ ($d \le$ length of the segment $XY$), we are at the point on the segment $XY$ whose distance from $X$ is $d$.
The Constraints guarantee that the distance between the points $(0, 0)$ and $(A, B)$ is at least $1$.

Constraints

  • All values in input are integers.
  • $0 \le A,B \le 1000$
  • $(A,B) \neq (0,0)$

Input

Input is given from Standard Input in the following format:

$A$ $B$

Output

Let $(x, y)$ be our coordinates after the move. Print $x$ and $y$ in this order, separated by a space.
Your output is considered correct when, for each printed value, the absolute or relative error from the judge's answer is at most $10^{−6}$.


Sample Input 1

3 4

Sample Output 1

0.600000000000 0.800000000000

Printing 0.5999999999 0.8000000001, for example, would also be accepted.


Sample Input 2

1 0

Sample Output 2

1.000000000000 0.000000000000

We may arrive at $(A, B)$.


Sample Input 3

246 402

Sample Output 3

0.521964870245 0.852966983083

Input

题意翻译

给定一个向量的坐标表示,求同向模长为 $ 1 $ 的向量的坐标表示。

Output

分数:$200$分

问题描述

在一个二维平面上,从点$(0,0)$出发,朝着点$(A, B)$移动距离为$1$。求移动后的坐标。

这里,从点$X$到点$Y$移动距离为$d$($d \le$ 线段$XY$的长度),我们位于线段$XY$上距离$X$为$d$的点。

约束条件保证了点$(0, 0)$和$(A, B)$之间的距离至少为$1$。

约束条件

  • 输入中的所有值都是整数。
  • $0 \le A,B \le 1000$
  • $(A,B) \neq (0,0)$

输入

输入数据从标准输入按以下格式给出:

$A$ $B$

输出

设移动后的坐标为$(x, y)$。将$x$和$y$按空格分隔的方式打印出来。

当打印出的每个值与裁判答案的绝对或相对误差不超过$10^{−6}$时,你的输出将被认为是正确的。


样例输入1

3 4

样例输出1

0.600000000000 0.800000000000

打印出如0.5999999999 0.8000000001这样的答案也是可以接受的。


样例输入2

1 0

样例输出2

1.000000000000 0.000000000000

我们可能到达$(A, B)$。


样例输入3

246 402

样例输出3

0.521964870245 0.852966983083

加入题单

算法标签: