Codeforces 982E Billiard 扩展欧几里得+思维

本文介绍了一道Codeforces编程题目,涉及台球在矩形桌面上的运动轨迹。根据初始位置和速度,需要判断球是否会落入袋中及落入哪个袋。通过分析球的反射路径和应用扩展欧几里得算法,可以找到问题的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


E. Billiard
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Consider a billiard table of rectangular size n×mn×m with four pockets. Let's introduce a coordinate system with the origin at the lower left corner (see the picture).

There is one ball at the point (x,y)(x,y) currently. Max comes to the table and strikes the ball. The ball starts moving along a line that is parallel to one of the axes or that makes a 4545∘ angle with them. We will assume that:

  1. the angles between the directions of the ball before and after a collision with a side are equal,
  2. the ball moves indefinitely long, it only stops when it falls into a pocket,
  3. the ball can be considered as a point, it falls into a pocket if and only if its coordinates coincide with one of the pockets,
  4. initially the ball is not in a pocket.

Note that the ball can move along some side, in this case the ball will just fall into the pocket at the end of the side.

Your task is to determine whether the ball will fall into a pocket eventually, and if yes, which of the four pockets it will be.

Input

The only line contains 6

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值