Logo
(追記) (追記ここまで)

24590번 - Circle Bounce 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB71494167.213%

문제

You are standing by the wall in a large, perfectly circular arena and you throw a tennis ball hard against some other part of the arena. After a given number of bounces, where does the tennis ball next strike the wall?

Map the arena as a unit circle centered at the origin, with you standing at the point $(-1, 0)$. You throw the ball with a direction given by a slope in the coordinate plane of a rational fraction $a/b$. Each bounce is perfect, losing no energy and bouncing from the wall with the same angle of reflection as the angle of incidence to a tangent to the wall at the point of impact.

After $n$ bounces, the ball strikes the circle again at some point $p$ which has rational coordinates that can be expressed as $(r/s, t/u)$. Output the fraction $r/s$ modulo the prime $M = 1{,}000{,}000{,}007$.

It can be shown that the $x$ coordinate can be expressed as an irreducible fraction $r/s,ドル where $r$ and $s$ are integers and $s \not\equiv 0 \pmod M$. Output the integer equal to $r\cdot s^{-1} \pmod M$. In other words, output an integer $k$ such that 0ドル \le k < M$ and $k\cdot s \equiv r \pmod M$.

For example, if we throw the ball with slope 1ドル/2$ and it bounces once, it first strikes the wall at coordinates $(3/5, 4/5)$. After bouncing, it next strikes the wall at coordinates $(7/25, -24/25)$. The modular inverse of 25ドル$ with respect to the prime $M$ is 280ドル{,}000{,}002,ドル and the final result is thus 7ドル\cdot 280{,}000{,}002 \pmod M = 960{,}000{,}007$.

입력

The single line of input will contain three integers $a,ドル $b$ (1ドル \le a,b \le 10^9, \gcd(a,b)=1$) and $n$ (1ドル \le n \le 10^{12}$), where $a/b$ is the slope of your throw, and $n$ is the number of bounces. Note that $a$ and $b$ are relatively prime.

출력

Output a single integer value as described above.

Note that Sample 2 corresponds to the example in the problem description.

제한

예제 입력 1

1 1 3

예제 출력 1

1000000006

예제 입력 2

1 2 1

예제 출력 2

960000007

예제 입력 3

11 63 44

예제 출력 3

22

예제 입력 4

163 713 980

예제 출력 4

0

힌트

출처

ICPC > Regionals > North America > Pacific Northwest Regional > 2021 ICPC Pacific Northwest Region > Division 1 A번

ICPC > Regionals > North America > South Central USA Regional > 2021 South Central USA Regional Contest > Division 1 B번

ICPC > Regionals > North America > Northeast North America Regional > 2021 Northeast North America Regional Contest F번

ICPC > Regionals > North America > Southeast USA Regional > 2021 Southeast USA Regional Programming Contest > Division 1 B번

  • 문제를 만든 사람: Tomas Rokicki
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /