CF BUDDY
← Problems·

1763E · Node Pairs

2200 · dp, graphs, math

Problem: Let's call an ordered pair of nodes (u,v)(u, v) in a directed graph unidirectional if uvu \neq v, there exists a path from uu to vv, and there are no paths from vv to uu.

A directed graph is called pp-reachable if it contains exactly pp ordered pairs of nodes (u,v)(u, v) such that u<vu < v and uu and vv are reachable from each other. Find the minimum number of nodes required to create a pp-reachable directed graph.

Also, among all such pp-reachable directed graphs with the minimum number of nodes, let GG denote a graph which maximizes the number of unidirectional pairs of nodes. Find this number.

Input Format: The first and only line contains a single integer pp (0p21050 \le p \le 2 \cdot 10^5) — the number of ordered pairs of nodes.

Output Format: Print a single line containing two integers — the minimum number of nodes required to create a pp-reachable directed graph, and the maximum number of unidirectional pairs of nodes among all such pp-reachable directed graphs with the minimum number of nodes.

Note: In the first test case, the minimum number of nodes required to create a 33-reachable directed graph is 33. Among all 33-reachable directed graphs with 33 nodes, the following graph GG is one of the graphs with the maximum number of unidirectional pairs of nodes, which is 00.

Sample Cases

Case 1

Input

3

Output

3 0

Case 2

Input

4

Output

5 6

Case 3

Input

0

Output

0 0

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback