結果

問題 No.1520 Zigzag Sum
ユーザー kotatsugamekotatsugame
提出日時 2021-05-28 21:34:11
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 212 ms / 2,000 ms
コード長 435 bytes
コンパイル時間 725 ms
コンパイル使用メモリ 67,192 KB
実行使用メモリ 7,808 KB
最終ジャッジ日時 2024-04-24 23:45:30
合計ジャッジ時間 2,533 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
7,808 KB
testcase_01 AC 8 ms
7,680 KB
testcase_02 AC 177 ms
7,552 KB
testcase_03 AC 197 ms
7,680 KB
testcase_04 AC 196 ms
7,552 KB
testcase_05 AC 212 ms
7,680 KB
testcase_06 AC 198 ms
7,680 KB
testcase_07 AC 193 ms
7,552 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<atcoder/modint>
using namespace std;
using mint=atcoder::modint1000000007;
mint fac[4<<17],inv[4<<17];
main()
{
	fac[0]=1;
	for(int i=1;i<4<<17;i++)fac[i]=fac[i-1]*i;
	inv[(4<<17)-1]=1/fac[(4<<17)-1];
	for(int i=(4<<17)-1;i--;)inv[i]=inv[i+1]*(i+1);
	int T;cin>>T;
	for(;T--;)
	{
		int H,W;cin>>H>>W;
		if(H==1||W==1)cout<<0<<endl;
		else
		{
			cout<<(2*fac[H+W-3]*inv[H-2]*inv[W-2]).val()<<endl;
		}
	}
}
0