結果

問題 No.1836 Max Matrix
ユーザー akasinnakasinn
提出日時 2022-02-12 00:15:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 598 bytes
コンパイル時間 2,053 ms
コンパイル使用メモリ 199,264 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-10 07:34:26
合計ジャッジ時間 4,108 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 2 ms
4,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 53 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
const ll mod=998244353;//≒10⁹ 素数
int mpow(int x,int y){//mod付きx^y
//x^(a+b+c)=x^a × x^b × x^cを利用
  bitset<32> btst(y);
  ll ans=1;
  for(int i=0;i<32;i++){
    if(btst.test(i)){
      ans=(ans*x)%mod;
    }
    x=(x*x)%mod;
  }
  return ans;
}
int main(){
  ll h,w,m,ans=0;
  cin>>h>>w>>m;
  for(int i=0;i<m;i++){//i=最小値-1
    ll a=(mpow(m-i,h)-mpow(m-i-1,h)+mod)%mod;
    ll b=(mpow(m-i,w)-mpow(m-i-1,w)+mod)%mod;
    //cout<<a<<' '<<b<<endl;
    ans=(ans+a*b)%mod;
  }
  
  cout<<ans<<endl;
  return 0;
}
0