Universal Cup Judging System

Universal Cup

Limite de temps : 4.0 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓
Statistiques

In the Square Kingdom, $n$ residents numbered from $1$ to $n$ live alone on top of a tall stone pillar. The height of the pillar for the $i$-th resident is $\left(i + \frac{b}{a}\right)^2$ units above the ground.

Since everyone lives so high up, the only way to visit a neighbor is by using a ladder. The kingdom builds one ladder for every pair of residents. The length of each ladder is exactly the absolute difference in height between the two pillars it connects.

With $\frac{n(n-1)}{2}$ ladders in total, it becomes hard to manage them all. You are asked for the length of the $k$-th ladder in ascending order of length. This information will help the kingdom plan repairs, deliveries, and community events.

Input

The only line contains four integers $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$), and $b$ ($0 \le b \le 10^{12}$).

Output

Output a line containing two integers $p$ and $q$, denoting that the length of the $k$-th ladder in ascending order of length can be represented as $\frac{p}{q}$ with two integers $p$ and $q$ ($p \ge 0$, $q \ge 1$, $\gcd(p, q) = 1$), where $\gcd(p, q)$ is the greatest common divisor of $p$ and $q$.

Examples

Sample Input 1

3 1 3 1

Sample Output 1

11 3

Sample Input 2

3 2 3 1

Sample Output 2

17 3

Sample Input 3

3 3 3 1

Sample Output 3

28 3

Sample Input 4

1414215 1000000000000 1000000 1000000000000

Sample Output 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.