No.2207 pCr Test
タグ : / 解いたユーザー数 32
作問者 :
testestest
/ テスター :
tatyam
Problem Statement
You are given an integer $N$. Do there exist a prime $p$ and a non-negative integer $r$ such that the binomial coefficient ${}_pC_r$ is equal to $N$?
Input
$k$ $p_1$ $e_1$ $\vdots$ $p_k$ $e_k$
- $N$ is given in its prime factorized form, where $N=\prod_{i=1}^{k}p_i^{e_i}$
- $k\geq 1$
- $2\leq p_1 < \ldots < p_k \leq 10^7$
- $1\leq e_i\leq 10^7$
Output
If there exist a prime $p$ not exceeding $10^{49}$ and a non-negative integer $r$ satisfying $N={}_pC_r$, print $p,r$ in this order, separated by a space, followed by a newline. If there are multiple solutions, any of them will be accepted.
If no such $p,r$ exist, print -1 -1 instead, followed by a newline.
Extra output at the end will still be accepted.
Sample
Sample 1
Input
2 2 1 5 1
Output
5 2
Outputs such as 5 3 will also be accepted.
Sample 2
Input
2 2 2 5 1
Output
-1 -1
There is no $(p,r)$ satisfying ${}_pC_r=20$. Note that $p$ must be prime.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。