Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define FIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
- //#define mod 998244353//1000000007
- #define eps 1e-9
- #define setbits __builtin_popcount
- #define gcd __gcd
- #define rep(i,a,b) for(int i=a;i<=b;i++)
- #define repr(i,b,a) for(int i=b;i>=a;i--)
- #define forn(i,n) for(int i=0;i<n;i++)
- #define aint(a) a.begin(), a.end()
- #define pb push_back
- #define endl "\n"
- #define ff first
- #define ss second
- #define asort(c) sort(aint(c))
- #define lbpos(x,v) (int)(lower_bound(aint(v),x)-v.begin())//=v.size()==>No LB
- #define ubpos(x,v) (int)(upper_bound(aint(v),x)-v.begin())//=v.size()==>No UB
- #define PI 3.14159265358979323846
- #define int long long
- typedef vector<int> vi;
- typedef pair<int, int> ii;
- typedef vector<ii> vii;
- typedef long double ld;
- #define debug(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
- template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
- template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
- {
- const char* comma = strchr(names + 1, ',');
- std::cerr.write(names, comma - names) << " = " << arg1;
- ZZ(comma, args...);
- }
- clock_t time_p=clock();
- void timer()
- {
- time_p=clock()-time_p;
- cerr<<"Execution Time: "<<(double)(time_p)/CLOCKS_PER_SEC<<"\n";
- }
- bool allSame(string s)
- {
- return (s.find_first_not_of(s[0]) == string::npos);
- }
- const int maxn = 2005;
- const int mod=998244353;
- int C[maxn + 1][maxn + 1];
- void ncr()
- {
- C[0][0] = 1;
- for (int n = 1; n <= maxn; ++n)
- {
- C[n][0] = C[n][n] = 1;
- for(int k = 1; k < n; ++k)
- C[n][k] = (C[n - 1][k - 1] + C[n - 1][k])%mod;
- }
- }
- int fast_exp(int base, int exp,int M)
- {
- int res=1LL;
- while(exp>0) {
- if(exp%2==1) res=(res*base)%M;
- base=(base*base)%M;
- exp/=2;
- }
- return res%M;
- }
- int32_t main()
- {
- FIO;
- #ifndef ONLINE_JUDGE
- freopen("input.txt","r",stdin);
- freopen("output.txt","w",stdout);
- #endif
- int n,m,k,ans=0;
- cin>>n>>m>>k;
- ncr();
- if(k==0)
- {
- cout<<m; return 0;
- }
- ans=(C[n-1][k]*(fast_exp(m-1,k,mod)*m)%mod)%mod;
- cout<<ans;
- timer();
- return 0;
- }
Add Comment
Please, Sign In to add comment