Universal Cup Judging System

Universal Cup

时间限制: 4.0 s 内存限制: 1024 MB 总分: 100 可 Hack ✓
统计

제곱 왕국에서는 $1$번부터 $n$번까지 번호가 매겨진 $n$명의 주민이 각각 높은 돌기둥 꼭대기에 혼자 살고 있습니다. $i$번째 주민이 사는 돌기둥의 지면으로부터의 높이는 $\left(i + \frac{b}{a}\right)^2$ 단위입니다.

모두가 아주 높은 곳에 살기 때문에, 이웃을 방문하는 유일한 방법은 사다리를 이용하는 것입니다. 왕국은 모든 주민 쌍마다 사다리를 하나씩 설치합니다. 각 사다리의 길이는 그 사다리가 연결하는 두 돌기둥의 높이 차이의 절댓값과 정확히 같습니다.

사다리가 총 $\frac{n(n-1)}{2}$개나 되다 보니 이를 모두 관리하기가 쉽지 않습니다. 사다리를 길이의 오름차순으로 정렬했을 때 $k$번째 사다리의 길이를 구해 주십시오. 이 정보는 왕국이 수리, 배달 및 공동체 행사를 계획하는 데 도움이 될 것입니다.

입력

유일한 줄에 네 정수 $n$($2 \le n \le 10^{12}$), $k$($1 \le k \le \min\left\{\frac{n(n-1)}{2}, 10^{12}\right\}$), $a$($1 \le a \le 10^6$), 그리고 $b$($0 \le b \le 10^{12}$)가 주어집니다.

출력

두 정수 $p$와 $q$를 한 줄에 출력하십시오. 이는 길이의 오름차순으로 $k$번째 사다리의 길이를 두 정수 $p$와 $q$($p \ge 0$, $q \ge 1$, $\gcd(p, q) = 1$)를 사용하여 $\frac{p}{q}$로 나타낼 수 있음을 의미하며, 여기서 $\gcd(p, q)$는 $p$와 $q$의 최대공약수입니다.

예제

예제 입력 1

3 1 3 1

예제 출력 1

11 3

예제 입력 2

3 2 3 1

예제 출력 2

17 3

예제 입력 3

3 3 3 1

예제 출력 3

28 3

예제 입력 4

1414215 1000000000000 1000000 1000000000000

예제 출력 4

4823373069559 1

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#2666EditorialOpen$O(\sqrt{k})$ by GPT6 ProAnonymousView

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.