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;
}