题目描述

In computer science, a character is a letter, a digit, a punctuation mark or some other similar symbol. Since computers can only process numbers, number codes are used to represent characters, which is known as character encoding. A character encoding system establishes a bijection between the elements of an alphabet of a certain size n and integers from 0 to n−1. Some well known character encoding systems include American Standard Code for Information Interchange (ASCII), which has an alphabet size 128, and the extended ASCII, which has an alphabet size 256.

For example, in ASCII encoding system, the word wdy is encoded as [119, 100, 121], while jsw is encoded as  [106, 115, 119]. It can be noticed that both 119+100+121=340 ,and 106+115+119=340 then the sum of the encoded numbers of the two words are equal. In fact, there are in all 903 such words of length 3 in an encoding system of alphabet size 128 (in this example, ASCII). The problem is as follows: given an encoding system of alphabet size n where each character is encoded as a number between 0 and n−1 inclusive, how many different words of length m are there, such that the sum of the encoded numbers of all characters is equal to k?

Since the answer may be large, you only need to output it modulo 998244353.

输入

The first line of input is a single integer T (1≤T≤400), the number of test cases.
Each test case includes a line of three integers n,m,k (1≤n,m≤105,0≤k≤105), denoting the size of the alphabet of the encoding system, the length of the word, and the required sum of the encoded numbers of all characters, respectively.
It is guaranteed that the sum of n, the sum of m and the sum of k don't exceed 5×106, respectively.

输出

For each test case, display the answer modulo 998244353 in a single line.

样例输入

4
2 3 3
2 3 4
3 3 3
128 3 340

样例输出

1
0
7
903
题意是从0-n-1这n个数中选m个,和为k的方案数,可以重复选择
也就是将k分成m份,每份为0-n-
也就是将k+m分成m份,每份为1-n
假设没有上限n,答案就是隔板法 C(k+m-,m-)
这里面肯定计算了有大于n的情况
假设我们从这k+m里面拿出一个n,然后将剩下的分成非空的m份,再把这个n加到其中的一份当中,那么至少有一份是大于n的,同样的道理,如果拿出c个n,那么至少有c份是大于n的,因为这里是至少,而不是一定有c份大于n,这其中有包含关系,所以需要容斥一下
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int p=;
const int N=1e6+;
int T,n,m,k;
ll fac[N],inv[N];
ll poww(ll x,int y)
{
ll ret=;
while(y)
{
if (y&) ret=ret*x%p;
x=x*x%p;
y>>=;
}
return ret;
}
void pre()
{
fac[]=;
for (int i=;i<N;i++) fac[i]=fac[i-]*i%p;
inv[N-]=poww(fac[N-],p-);
for (int i=N-;i>=;i--) inv[i]=inv[i+]*(i+)%p;
}
ll C(int a,int b)
{
return fac[a]*inv[b]%p*inv[a-b]%p;
}
ll solve(int n,int m,int k)
{
if(1ll*(n-)*m<k) return ; ll ans=C(k+m-,m-);
int nn=k/n;
for (int i=;i<=nn;i++)
{
ll tmp=C(k-i*n+m-,m-)*C(m,i)%p; if (i&) ans=(ans-tmp+p)%p;
else ans=(ans+tmp)%p;
}
return ans;
}
int main()
{
pre();
scanf("%d",&T);
while (T--)
{
scanf("%d%d%d",&n,&m,&k);
printf("%lld\n",solve(n,m,k));
}
return ;
}

杭电多校第八场-A-Character Encoding的更多相关文章

  1. Acesrc and Travel(2019年杭电多校第八场06+HDU6662+换根dp)

    题目链接 传送门 题意 两个绝顶聪明的人在树上玩博弈,规则是轮流选择下一个要到达的点,每达到一个点时,先手和后手分别获得\(a_i,b_i\)(到达这个点时两个人都会获得)的权值,已经经过的点无法再次 ...

  2. 2019 杭电多校第八场 HDU - 6665 Calabash and Landlord 两矩形分平面

    题意 给出两个矩形,问这两个矩形把平面分成了几部分. 分析 不需要什么高级技能,只需 “简单” 的分类讨论. (实在太难写了,对拍找出错误都不想改 推荐博客,其中有个很好的思路,即只讨论答案为2,3, ...

  3. [2019杭电多校第八场][hdu6667]Roundgod and Milk Tea

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6667 题目大意是说n个班级,每个班级有ai人和bi杯茶,每个人只能喝其他班的茶并且只能喝一杯.问最多有 ...

  4. 可持久化线段树的学习(区间第k大和查询历史版本的数据)(杭电多校赛第二场1011)

    以前我们学习了线段树可以知道,线段树的每一个节点都储存的是一段区间,所以线段树可以做简单的区间查询,更改等简单的操作. 而后面再做有些题目,就可能会碰到一种回退的操作.这里的回退是指回到未做各种操作之 ...

  5. HDU 5745 La Vie en rose (DP||模拟) 2016杭电多校联合第二场

    题目:传送门. 这是一道阅读理解题,正解是DP,实际上模拟就能做.pij+1 指的是 (pij)+1不是 pi(j+1),判断能否交换输出即可. #include <iostream> # ...

  6. HDU 5744 Keep On Movin (贪心) 2016杭电多校联合第二场

    题目:传送门. 如果每个字符出现次数都是偶数, 那么答案显然就是所有数的和. 对于奇数部分, 显然需要把其他字符均匀分配给这写奇数字符. 随便计算下就好了. #include <iostream ...

  7. HDU 5742 It's All In The Mind (贪心) 2016杭电多校联合第二场

    题目:传送门. 题意:求题目中的公式的最大值,且满足题目中的三个条件. 题解:前两个数越大越好. #include <iostream> #include <algorithm> ...

  8. HDU 5734 Acperience (公式推导) 2016杭电多校联合第二场

    题目:传送门. #include <iostream> #include <algorithm> #include <cstdio> #include <cs ...

  9. HDU 5724 Chess (状态压缩sg函数博弈) 2016杭电多校联合第一场

    题目:传送门. 题意:有n行,每行最多20个棋子,对于一个棋子来说,如果他右面没有棋子,可以移动到他右面:如果有棋子,就跳过这些棋子移动到后面的空格,不能移动的人输. 题解:状态压缩博弈,对于一行2^ ...

随机推荐

  1. Kali渗透测试工具-netcat

    netcat被称作是网络工具当中的瑞士军刀,短小却功能强大 1.端口扫描 nc -nvz 目标IP 端口范围 eg: nc -nvz 192.168.1.105 1-65535 -n参数是不要使用DN ...

  2. [leetcode-718-Maximum Length of Repeated Subarray]

    Given two integer arrays A and B, return the maximum length of an subarray that appears in both arra ...

  3. v-if或者v-repeat等不起作用

    v-if或者v-for等不起作用 在项目中,有时遇到了v-if或v-for等形式时,页面没起作用.以下可能是出现这些问题的原因: 1.绑定值是接口返回的某个属性值,而这个属性值不存在data()中,这 ...

  4. Alpha发布文案加美工展示

    目录 团队简介 项目进展 组内分工 队员总结 后期计划 一.团队简介 二.项目进展 从选题发布到今天的Alpha发布,我们团队经历了许许多多的磨难.我们最终设计了如下的功能:首页.班级.个人.更多.打 ...

  5. 初学c#(又要打代码了好难)

    因为我原来从没有学过C#,所以要重新看一个语言的基本语法,仔细阅读了老师的作业要求,发现第一个10分的作业如果要用c语言写我是可以完成的,于是定个小目标就是在周日前完成作业的第一步.今天我在菜鸟教程的 ...

  6. 学霸系统PipeLine功能规格说明书

    学霸系统PipeLine功能规格说明书共分为以下三部分: 1.产品面向用户群体 2.用户使用说明 3.产品功能具体实现 1.产品面向用户群体 我们这组的项目并不是传统意义上能发布并进行展示的项目,因此 ...

  7. Python的time,datetime,string相互转换

    #把datetime转成字符串 def datetime_toString(dt): return dt.strftime("%Y-%m-%d-%H") #把字符串转成dateti ...

  8. Filezilla 绿色版 禁止升级 能用。

    FileZilla还是挺好用的,但是如果钟情于 绿色版的话,肯定首选是 免安装绿色版.但是呢,能找到的所谓的免升级 绿色版,都不能用.只要是打开软件了,就会在你还没有设置更新之前,就已经升级号了.并且 ...

  9. Java SE1.6中的Synchronized

    1 引言 在多线程并发编程中Synchronized一直是元老级角色,很多人都会称呼它为重量级锁,但是随着Java SE1.6对Synchronized进行了各种优化之后,有些情况下它并不那么重了,本 ...

  10. mysql(一) 关联查询的方式

    mysql做关联查询时,一般使用join....on.....的语法. 但还有其它两种语法形式,三者的主要区别在于书写形式,其余方面并无太多差异. 如下三种形式: select * from trad ...