結果

問題 No.2527 H and W
ユーザー anonymouslyanonymously
提出日時 2023-11-03 23:13:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 582 ms / 2,000 ms
コード長 912 bytes
コンパイル時間 1,848 ms
コンパイル使用メモリ 167,848 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-11-03 23:14:01
合計ジャッジ時間 5,364 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 557 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 135 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 54 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 191 ms
4,348 KB
testcase_13 AC 203 ms
4,348 KB
testcase_14 AC 143 ms
4,348 KB
testcase_15 AC 3 ms
4,348 KB
testcase_16 AC 25 ms
4,348 KB
testcase_17 AC 582 ms
4,348 KB
testcase_18 AC 111 ms
4,348 KB
testcase_19 AC 68 ms
4,348 KB
testcase_20 AC 81 ms
4,348 KB
testcase_21 AC 77 ms
4,348 KB
testcase_22 AC 75 ms
4,348 KB
testcase_23 AC 134 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long MODULO=998244353L;

long modinv(long a) {
    long b=MODULO, u=1L, v=0L;
    while(b){
        long t=a/b;
        a-=(t*b);
        swap(a, b);
        u-=(t*v);
        swap(u, v);
    }
    u%=MODULO; 
    if(u<0)u+=MODULO;
    return u;
}

long modplus(long a,long b){
	long res=(a+b)%MODULO;
	if(res<0)res+=MODULO;
	return res;
}

long modtimes(long a,long b){
	return (a*b)%MODULO;
}

long comb(long n,long r){
	if(r*2>n){
		return comb(n,n-r);
	}else{
		long nCr=1L;
		for(long i=1;i<=r;i++){
			nCr=modtimes(modtimes(nCr,n-r+i),modinv(i));
		}
		return nCr;
	}
}

int main(){
	long h,w,k;
	cin >> h >> w >> k;
	long ans=0L;
	for(long i=max(1L,(k+w-1)/w);i<=min(h,k);i++){
		if(k%i==0){
			long j=k/i;
			//i行、j列を残して選択し、赤くする
			ans=modplus(ans,modtimes(comb(h,i),comb(w,j)));
		}
	}
	cout << ans << endl;
	return 0;
}
0