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

19056번 - Oleg and Data Science 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 256 MB33201470.000%

문제

Nowadays, everybody has heard about machine learning, neural networks and big data. And so has the student Oleg, who also wants to be in trend. He began to work hard at analyzing various datasets with Python. It's so nice to come to co-working, add a couple of layers to the neural network and, leaning back in the chair, sip the smoothies while the computer processes gigabytes of data! But today, something went wrong, and Oleg asks for your help.

Initially, he had an array $a$ containing very important data: all integers from $L$ to $R,ドル inclusive. Then Oleg wrote a function $f (a, m)$ which returns a new array where each integer is replaced by its remainder modulo $m$. Finally, Oleg mistyped and executed the line $a = f (a, Q),ドル thereby replacing the original array $a$! To assess the scale of the tragedy, he wants to calculate the number of such positive integers $X$ that, regardless of the content of the original array $a,ドル the result of the function $f (a, X)$ will be the same as if Oleg had not executed that hapless line.

If the problem is not clear yet, here is the mathematical statement. It is required to calculate the number of such positive integers $X$ that, for all integers $S$ from the segment $[L, R],ドル it is true that $$((S \bmod Q) \bmod X) = (S \bmod X)\text{.}$$

입력

The only line contains three integers separated by spaces: $L,ドル $R$ and $Q$ (1ドル \leq L, R, Q \leq 10^{12},ドル $L \leq R$).

출력

If the number of suitable positive integers $X$ is finite, print it. Otherwise, print the word "infinity".

제한

예제 입력 1

1 1 1

예제 출력 1

1

예제 입력 2

3 5 2

예제 출력 2

2

예제 입력 3

1 10 10

예제 출력 3

4

예제 입력 4

1 1 2

예제 출력 4

infinity

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2017 > Day 3: Ural Contest B번

Contest > Open Cup > 2017/2018 Season > Stage 2: Grand Prix of Ural B번

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

출처

대학교 대회

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

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