2020ICPC 江西省大学生程序设计竞赛

G Mathematical Practice
链接:https://ac.nowcoder.com/acm/contest/8827/G

题目描述

Kamishirasawa Keine always says, “If you don’t know what to do, why not give mathematical practice a try.”

However, Cirno is way too much talented to work on simple problems. Therefore, you are now tasked to crack one.

We consider one operation on a set S as selecting m subsets of S in order (You can select the same subset multiple times and the selected subset can be empty).

Now you need to figure out how many possible operations that the m selected subsets are pairwise disjoint.

As the answer may get very large, you need to print the answer after modulo 998244353.

输入描述:
The input contains one line with two integers n and m (1≤n,m≤109), where n is the size of set S and m is the number of subsets to be selected in one operation.

输出描述:
Printone integer, the number of possible operations above after modulo 998244353.
示例1
输入
3 2
输出
27
示例2
输入
1000 25
输出
605425003

题意
长度为n的集合取出m个子集,可以有多少次操作。

思路
看数据规模1e9,之前手算了几组数据,使用组合数求得,但是这个数据规模肯定不是这么做,所以我们考虑一些更快的操作,比如左移运算,我们想到快速幂,看到3 2是27,1 1是2,2 1 是4 ,2 2是8,我们可以猜一手(m+1)^ n,过了第二组样例,基本稳了,只能说傻逼题目。

代码

#include <bits/stdc++.h>
typedef long long ll;
const ll mod = 998244353;
using namespace std;
namespace fastIO {
    inline void input(int& res) {
        char c = getchar();res = 0;int f = 1;
        while (!isdigit(c)) { f ^= c == '-'; c = getchar(); }
        while (isdigit(c)) { res = (res << 3) + (res << 1) + (c ^ 48);c = getchar(); }
        res = f ? res : -res;
    }
    inline ll qpow(ll a, ll b) {
        ll ans = 1, base = a;
        while (b) {
            if (b & 1) ans = (ans * base % mod +mod )%mod;
            base = (base * base % mod + mod)%mod;
            b >>= 1;
        }
        return ans;
    }
}
using namespace fastIO;
const int N = 1e6 + 5;
int Case,n,x,y,m;
int main(){
	Case=1;
	//input(Case);
	while(Case--){
		input(n),input(m);
		printf("%lld",qpow(m+1,n));
	}
	return 0;
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值