2018 Multi-University Training Contest 8--Character Encoding--hdu--6397

Character Encoding

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 932    Accepted Submission(s): 358

 

Problem Description

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, thus 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.

Input

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.

Output

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

Sample Input

4

2 3 3

2 3 4

3 3 3

128 3 340

Sample Output

1

0

7

903

Source

2018 Multi-University Training Contest 

题意:

给你N,M,K三个数字,询问你在0~n-1中,选M位数字和为K,一共有多少种方法。

题解:

看了讲解,学习了一波生成函数做法。

 

我们先不看k,只看n和m

当n=2时

     0  1   2   3   4   5   6   7   8  9 10 11...

0   1

1   1  1

2   1  2   1

3   1  3   3   1

4   1  4   6   4   1

5   1  5  10  10   5   1

6   1  6  15  20  15   6   1

7   1  7  21  35  35  21   7   1

8   1  8  28  56  70  56  28   8   1

9   1  9  36  84 126 126  84  36   9  1

10  1 10  45 120 210 252 210 120  45 10  1

11  1 11  55 165 330 462 462 330 165 55 11  1

很显然就是杨辉三角,直接二项式定理就可以了

当n=3是,也是类似的

     0   1   2   3   4    5    6      7      8     9   10  11  12

0:  1

1:  1   1   1

2:  1   2   3    2    1

3:  1   3   6    7    6   3    1

4:  1   4  10  16  19  16  10   4      1

5:  1   5  15  30  45  51  45   30   15    5   1

6:  1   6  21  50  90 126 141 126  90  50 21  6  1

 

生成公式:

(1+x+x^{2}+...+x^{n}) ^{m}

这个公式就是就可以表示第m行的结果,对应的系数就是展开式中x^i的系数,所以我们只需要求生成公式中x^k的系数即可。

那么我们就得对公式化简

(1+x+x^{2}+...+x^{n-1}) ^{m} \\ =(\frac{1-x^{n}}{1-x}) ^{m} \\ =(1-x^{n})^{m} (1-x) ^{-m}

根据泰勒展开:

可得

(1-x) ^{-m}=\sum_{i=0}^{\infty}C_{m+i-1} ^{i-1}\cdot x^{i}

所以

(1+x+x^{2}+...+x^{n-1}) ^{m} \\ =(\frac{1-x^{n}}{1-x}) ^{m} \\ =(1-x^{n})^{m} (1-x) ^{-m} \\ =\sum_{i=0}^{m} C_{m} ^{i} (-x^{n}) ^{i} \cdot \sum_{i=0}^{\infty} C_{m+i-1} ^{i-1}\cdot x^{i}

到了这一步,我们就可以直接计算了

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const int mod = 998244353;
const int maxn = 2e5+5;

ll f[maxn],ff[maxn],a[maxn],b[maxn];
int n,m,k;
//ll pow(ll a,ll b){
//	ll sum = 1;
//	while(b){
//		if(b&1){
//			sum = (sum * a) % mod;
//		}
//		a = (a*a)%mod;
//		b >>= 1;
//	}
//	return sum;
//}
ll inv(ll a,ll b) {
	if(a == 1)return 1;
	return inv(b%a,b)*(b-b/a)%b;
}
ll inline bit(int n,int m) {
	return f[n]*ff[m]%mod*ff[n-m]%mod;
}
int main() {
	f[0] =1;
	ff[0] = 1;
	for(int i = 1; i <=200000; i++) {
		f[i] = f[i-1]*i%mod;
		ff[i]=inv(f[i],mod);
		//printf("%d: %d %d\n",i,f[i],ff[i]);
	}
	int _;
	for(cin>>_; _; _--) {
		scanf("%d %d %d",&n,&m,&k);
		if(k == 0) {
			printf("1\n");
			continue;
		}
		if((ll)(n-1)*m<k) {
			printf("0\n");
			continue;
		}
		ll ans = 0;
		for(int i = 0; i<=k/n; i++) {
			ll x = bit(m,i)*bit(m+k-i*n-1,m-1)%mod;
			if(i%2==0) {
				ans = (ans+x)%mod;
			} else {
				ans=(ans-x+mod)%mod;
			}
		}
		printf("%lld\n",ans);
	}
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
大学生就业服务平台管理系统按照操作主体分为管理员和用户。管理员的功能包括学生档案管理、字典管理、试卷管理、试卷选题管理、试题表管理、考试记录表管理、答题详情表管理、错题表管理、法律法规管理、法律法规收藏管理、法律法规留言管理、就业分析管理、论坛管理、企业管理、简历管理、老师管理、简历投递管理、新闻资讯管理、新闻资讯收藏管理、新闻资讯留言管理、学生信息管理、宣传管理、学生管理、职位招聘管理、职位收藏管理、招聘咨询管理、管理员管理。用户的功能等。该系统采用了Mysql数据库,Java语言,Spring Boot框架等技术进行编程实现。 大学生就业服务平台管理系统可以提高大学生就业服务平台信息管理问题的解决效率,优化大学生就业服务平台信息处理流程,保证大学生就业服务平台信息数据的安全,它是一个非常可靠,非常安全的应用程序。 管理员权限操作的功能包括管理新闻信息,管理大学生就业服务平台信息,包括考试管理,培训管理,投递管理,薪资管理等,可以管理新闻信息。 考试管理界面,管理员在考试管理界面中可以对界面中显示,可以对考试信息的考试状态进行查看,可以添加新的考试信息等。投递管理界面,管理员在投递管理界面中查看投递种类信息,投递描述信息,新增投递信息等。新闻信息管理界面,管理员在新闻信息管理界面中新增新闻信息,可以删除新闻信息。新闻信息类型管理界面,管理员在新闻信息类型管理界面查看新闻信息的工作状态,可以对新闻信息的数据进行导出,可以添加新新闻信息的信息,可以编辑新闻信息信息,删除新闻信息信息。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值