Universal Cup Judging System

Universal Cup

Süre Sınırı: 4.0 s Bellek Sınırı: 1024 MB Toplam puan: 100 Hack'lenebilir ✓
İstatistikler

Nel Regno dei Quadrati, $n$ abitanti numerati da $1$ a $n$ vivono da soli in cima a un alto pilastro di pietra. L'altezza del pilastro per l'$i$-esimo abitante è di $\left(i + \frac{b}{a}\right)^2$ unità sopra il suolo.

Poiché tutti vivono così in alto, l'unico modo per fare visita a un vicino è usare una scala. Il regno costruisce una scala per ogni coppia di abitanti. La lunghezza di ciascuna scala è esattamente la differenza assoluta di altezza tra i due pilastri che collega.

Con $\frac{n(n-1)}{2}$ scale in totale, diventa difficile gestirle tutte. Ti viene chiesto di trovare la lunghezza della $k$-esima scala in ordine crescente di lunghezza. Questa informazione aiuterà il regno a pianificare riparazioni, consegne ed eventi comunitari.

Input

L'unica riga contiene quattro interi $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$) e $b$ ($0 \le b \le 10^{12}$).

Output

Stampa una riga contenente due interi $p$ e $q$, indicando che la lunghezza della $k$-esima scala in ordine crescente di lunghezza può essere rappresentata come $\frac{p}{q}$ con due interi $p$ e $q$ ($p \ge 0$, $q \ge 1$, $\gcd(p, q) = 1$), dove $\gcd(p, q)$ è il massimo comun divisore di $p$ e $q$.

Esempi

Input di esempio 1

3 1 3 1

Output di esempio 1

11 3

Input di esempio 2

3 2 3 1

Output di esempio 2

17 3

Input di esempio 3

3 3 3 1

Output di esempio 3

28 3

Input di esempio 4

1414215 1000000000000 1000000 1000000000000

Output di esempio 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.