SHARE
TWEET

Untitled

a guest Dec 16th, 2018 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #include <bits/stdc++.h>
  3.  using namespace std;
  4. #define FIO                     ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
  5. //#define mod                     998244353//1000000007
  6. #define eps                     1e-9
  7. #define setbits                 __builtin_popcount
  8. #define gcd                     __gcd
  9. #define rep(i,a,b)              for(int i=a;i<=b;i++)
  10. #define repr(i,b,a)             for(int i=b;i>=a;i--)
  11. #define forn(i,n)               for(int i=0;i<n;i++)
  12. #define aint(a)                  a.begin(), a.end()
  13. #define pb                      push_back
  14. #define endl                    "\n"
  15. #define ff                      first
  16. #define ss                      second
  17. #define asort(c)                sort(aint(c))
  18. #define lbpos(x,v)              (int)(lower_bound(aint(v),x)-v.begin())//=v.size()==>No LB
  19. #define ubpos(x,v)              (int)(upper_bound(aint(v),x)-v.begin())//=v.size()==>No UB
  20. #define PI                      3.14159265358979323846
  21. #define int                     long long
  22. typedef  vector<int>                 vi;
  23. typedef  pair<int, int>              ii;
  24. typedef  vector<ii>                 vii;
  25. typedef  long double                 ld;
  26. #define debug(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
  27. template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
  28. template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
  29. {
  30.   const char* comma = strchr(names + 1, ',');
  31.   std::cerr.write(names, comma - names) << " = " << arg1;
  32.   ZZ(comma, args...);
  33. }
  34. clock_t time_p=clock();
  35. void timer()
  36. {
  37.     time_p=clock()-time_p;
  38.     cerr<<"Execution Time: "<<(double)(time_p)/CLOCKS_PER_SEC<<"\n";
  39. }
  40.  
  41. bool allSame(string s)
  42. {
  43.     return (s.find_first_not_of(s[0]) == string::npos);
  44. }
  45. const int maxn = 2005;
  46. const int mod=998244353;
  47. int C[maxn + 1][maxn + 1];
  48. void ncr()
  49. {
  50.   C[0][0] = 1;
  51.   for (int n = 1; n <= maxn; ++n)
  52.   {
  53.       C[n][0] = C[n][n] = 1;
  54.       for(int k = 1; k < n; ++k)
  55.           C[n][k] = (C[n - 1][k - 1] + C[n - 1][k])%mod;
  56.   }
  57. }
  58. int fast_exp(int base, int exp,int M)
  59. {
  60.     int res=1LL;
  61.     while(exp>0) {
  62.        if(exp%2==1) res=(res*base)%M;
  63.        base=(base*base)%M;
  64.        exp/=2;
  65.     }
  66.     return res%M;
  67. }
  68. int32_t main()
  69. {
  70.   FIO;
  71.   #ifndef ONLINE_JUDGE
  72.     freopen("input.txt","r",stdin);
  73.     freopen("output.txt","w",stdout);
  74.   #endif
  75.  
  76.   int n,m,k,ans=0;
  77.   cin>>n>>m>>k;
  78.   ncr();
  79.  
  80.   if(k==0)
  81.   {
  82.     cout<<m; return 0;
  83.   }
  84.  
  85.   ans=(C[n-1][k]*(fast_exp(m-1,k,mod)*m)%mod)%mod;
  86.   cout<<ans;
  87.  
  88.   timer();
  89.   return 0;
  90. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top