当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6442:GuGu Convolution

题目描述
As a newbie, XianYu is now learning generating function!
Given a series $\{a\}=(a_0,a_1,a_2,\cdots)$, we can easily define its exponential generating function as $g_{\{a\}}(x) = \sum\limits_{i=0}^{\infty}\dfrac{a_i}{i!}x^i$.
Now we define a series $\{u_c\}=(c^0,c^1,c^2,\cdots)$ and let $e_c$ represents the ${u_c}$ with $0$ filled in all its even items. Formally, ${\{e_c\}}=(0,c^1,0,c^3,0,c^5,\cdots)$.

'Do you know convolution?'
'GU GU.' GuGu utters.
'Well, let me show you.
Given two generating function $g_{\{a\}}$ and $g_{\{b\}}$, the convolution can be represented as $G(x)=(g_{\{a\}}*g_{\{b\}})(x)=\sum\limits_{n=0}^{\infty}(\sum\limits_{i+j=n}a_ib_j)x^n$.
It is quite easy, right?'
'GU GU.' GuGu utters.
'Ok. Now you have to find the coefficient of $x^n$ of the convolution $G(x)=(g_{\{u_A\}}*g_{\{e_\sqrt{B}\}})$, given $n$, $A$ and $B$.
Let $G_n$ representes that coefficient, you should tell me $n!G_n$.
You may know the severity of unsolving this problem.'

As GuGu is not that kind of good for it, it turns to you for help.
'GU GU!' GuGu thanks.

Hint

First Sample: $1!(\dfrac{1^0}{0!}\dfrac{\sqrt{1}^1}{1!} + \dfrac{1^1}{1!}\dfrac{0}{0!}) = 1 \sqrt{1}$
Second Sample: $2!(\dfrac{523^0}{0!}\dfrac{0}{2!} + \dfrac{523^1}{1!}\dfrac{\sqrt{12}^1}{1!} + \dfrac{523^2}{2!}\dfrac{0}{0!}) = 2092 \sqrt{3}$
P.S.: $1046\sqrt{12}$ is equal to the answer. However, $12$ has a factor $4=2^2$ so it can't be output directly.
输入解释
There is an integer $T$ in the first line, representing the number of cases.
Then followed $T$ lines, and each line contains four integers $A,B,n,p$. The meaning of $A,B,n$ is described above, and that of $p$ will be described in Output session.
$1\leq T \leq 10^5$
$1\leq A,B \leq 10^6$
$1\leq n \leq 10^{18}$
$1\leq p \leq 10^{9}$
输出解释
Let $\sum\limits_{i=1}^{q} a_i\sqrt{b_i}$ represents the answer, with $b_i \neq b_j, \gcd(b_i,b_j)=1, 1\leq i< j\leq q$, and none of $b_i$'s factors is square number.
Print $T$ lines only. Each line comes with a number $q$ and followed $q$ pairs of integers $a_i$ $b_i$, with $b_i$ in increasing order. Since $a_i$ may be large, please print $a_i\%p$ instead. All integers in the same line should be seperated by exactly one space.
You may find that each answer is unique.
输入样例
3
1 1 1 7
523 12 2 2100
1 1 1000000000000000000 998244353
输出样例
1 1 1
1 2092 3
1 121099884 1
来自杭电HDUOJ的附加信息
Recommend chendu

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6442

最后修改于 2020-10-25T23:31:22+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
5000/2500MS(Java/Others) 65536/65536K(Java/Others)