yukicoder-551
从 Trac 迁移的文章
这是从旧校内 Wiki 迁移的文章,可能存在一些样式问题,您可以向 memset0 反馈。
原文章内容如下:
{{{
#!html
<script type="text/x-mathjax-config">MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});</script>
<script type="text/javascript" async src="http://10.71.10.90/sfiction/tool/MathJax/MathJax-master/MathJax.js?config=TeX-MML-AM_CHTML"></script>
<style>
.input, pre {
display: block;
padding: 9.5px;
margin: 0 0 10px;
font-size: 13px;
line-height: 1.42857143;
color: #333;
word-break: break-all;
word-wrap: break-word;
background-color: #f5f5f5;
border: 1px solid #ccc;
border-radius: 4px;
}
</style>
}}}
== [https://yukicoder.me/problems/no/551 No.551 夏休みの思い出(2)] ==
=== Description ===
{{{
#!html
<p>给出一个奇素数$P$和它的原根$R$。有$Q$个询问,求$A_iX^2+B_iX+C_i \equiv 0 \pmod P$的解。</p>
}}}
=== Input ===
{{{
#!html
<p class="input">
$P$ $R$<br>
$Q$<br>
$A_1$ $B_1$ $C_1$<br>
$A_2$ $B_2$ $C_2$<br>
$\vdots$<br>
$A_Q$ $B_Q$ $C_Q$<br>
</p>
<p>$3 \le P \le 10^9, 2 \le R \le P-1, 1 \le Q \le 10^4, 1 \le A_i < P, 0 \le B_i, C_i < P$。</p>
}}}
=== Output ===
{{{
#!html
<p>第$i$行从小到大输出第$i$个方程的所有解,无解的话输出"-1"。</p>
}}}
=== Sample ===
==== Sample 1 ====
输入
{{{
#!html
<pre>
5 2
3
1 0 0
1 0 1
1 0 2
</pre>
}}}
输出
{{{
#!html
<pre>
0
2 3
-1
</pre>
}}}
==== Sample 2 ====
输入
{{{
#!html
<pre>
5 2
3
1 2 0
1 2 1
1 2 2
</pre>
}}}
输出
{{{
#!html
<pre>
0 3
4
1 2
</pre>
}}}
No.551 夏休みの思い出(2)
Description
给出一个奇素数$P$和它的原根$R$。有$Q$个询问,求$A_iX^2+B_iX+C_i \equiv 0 \pmod P$的解。
Input
$P$ $R$
$Q$
$A_1$ $B_1$ $C_1$
$A_2$ $B_2$ $C_2$
$\vdots$
$A_Q$ $B_Q$ $C_Q$
$3 \le P \le 10^9, 2 \le R \le P-1, 1 \le Q \le 10^4, 1 \le A_i < P, 0 \le B_i, C_i < P$。
Output
第$i$行从小到大输出第$i$个方程的所有解,无解的话输出"-1"。
Sample
Sample 1
输入
5 231 0 01 0 11 0 2
输出
02 3-1
Sample 2
输入
5 231 2 01 2 11 2 2
输出
0 341 2