_no0B

Untitled

Dec 6th, 2021
764
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. #define LL long long
  3. #define N ((int)6e4 + 5)
  4. #define MOD ((int)998244353 + 0)
  5. #define MAX ((int)1e9 + 7)
  6. #define MAXL ((ll)1e18 + 7)
  7. #define MAXP ((int)1e3 + 7)
  8. #define thr 1e-8
  9. #define pi acos(-1)  /// pi = acos ( -1 )
  10. #define fastio ios_base::sync_with_stdio(false),cin.tie(NULL)
  11. #define endl "\n"
  12.  
  13. using namespace std;
  14.  
  15. int fac[N] , ifac[N];
  16.  
  17. void PreProcess(int n)
  18. {
  19.     fac[0] = 1;
  20.     for(int i = 1 ; i <= n ; i++) fac[i] = 1LL*fac[i-1]*i % MOD;
  21.     ifac[n] = BigMod(fac[n] , MOD-2);
  22.     for(int i = n - 1 ; i >= 0  ; i--) ifac[i] = 1LL*ifac[i+1]*(i+1) % MOD;
  23. }
  24.  
  25. int main()
  26. {
  27.     PreProcess(1e7);
  28.     fastio;
  29.     int t;
  30.     cin>>t;
  31.     while(t--){
  32.         int n , m , ans;
  33.         LL k;
  34.         cin>>n>>m>>k;
  35.         if(k > n) ans = 0;
  36.         else{
  37.             ans = 1LL*fac[n] * ifac[k] % MOD * ifac[n - k] % MOD * BigMod(m , k) % MOD;
  38.         }
  39.         cout<<ans<<endl;
  40.     }
  41.  
  42.     return 0;
  43. }
  44.  
RAW Paste Data