QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#7774. 基础寄术练习题

Statistics

对于长度为 $ n $ 的序列 $ a $,定义 $ f(a)=\dfrac{1}{\prod\limits_{i=k}^ns_i} $,其中 $ s_i $ 为 $ \{a_n\} $ 的前缀和数组,$ k $ 是给定的常数且 $ 1\le k\le 2 $

考虑所有满足以下三个条件的序列 $ a $:

  • $ a $ 的长度为 $ n $。
  • $ \forall i,j $,$ a_i\ne a_j $。
  • $ 1\le a_i\le m $。

求它们的 $ f(a) $ 之和,答案对 $ p $ 取模。保证 $ p $ 是一个质数。

输入格式

第一行三个整数 $ n,m,k,p $,分别代表序列长度,序列元素的上界和模数。

输出格式

一行一个整数表示答案对 $ p $ 取模后的结果。

样例

输入样例 1
2 3 2 1000000007
输出样例 1
966666675
输入样例 2
3 5 2 998244353
输出样例 2
148276980
输入样例 3
6 10 2 1004535809
输出样例 3
622165218
输入样例 4
30 40 1 265371653
输出样例 4
179937201

限制与约定

对于所有数据,保证 $ 2\le n\le m\le 100 $,$ 10^8<p<1.07\times 10^9 $ 且 $ p $ 为质数,$ 1\le k\le 2 $。

  • Subtask 1 (10 pts):$ m\le 20 $。
  • Subtask 2 (25 pts):$ k=1 $。
  • Subtask 3 (15 pts):$ n=m\le 30 $。
  • Subtask 4 (10 pts):$ m\le 30 $。
  • Subtask 5 (15 pts):$ m\le 40 $。
  • Subtask 6 (10 pts):$ m\le 70 $。
  • Subtask 7 (15 pts):$ m\le 100 $。

时间限制:$ 2\text{s} $。

空间限制:$ 512\text{MB} $。

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.