結果

問題 No.498 ワープクリスタル (給料日編)
ユーザー kotatsugamekotatsugame
提出日時 2020-02-12 00:07:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 800 bytes
コンパイル時間 630 ms
コンパイル使用メモリ 70,808 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-08 21:55:31
合計ジャッジ時間 1,689 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 7 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 8 ms
6,676 KB
testcase_07 AC 8 ms
6,676 KB
testcase_08 AC 8 ms
6,676 KB
testcase_09 AC 8 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 3 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 7 ms
6,676 KB
testcase_19 AC 7 ms
6,676 KB
testcase_20 AC 7 ms
6,676 KB
testcase_21 AC 8 ms
6,676 KB
testcase_22 AC 8 ms
6,676 KB
testcase_23 AC 7 ms
6,676 KB
testcase_24 AC 7 ms
6,676 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:37:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   37 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;
long mod=1e9+7;
long F[99],I[99];
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
int gx,gy;
int x[5],y[5],n[5];
int K;
vector<int>tmp;
long dfs(int X,int Y,int id)
{
	if(id==5)
	{
		if(X==gx&&Y==gy)
		{
			int s=0;
			for(int k:tmp)s+=k;
			long ret=F[s];
			for(int k:tmp)ret=ret*I[k]%mod;
			return ret;
		}
		else return 0;
	}
	long ret=0;
	tmp.push_back(0);
	for(int k=0;k<=n[id];k++)
	{
		ret+=dfs(X,Y,id+1);
		tmp.back()++;
		X+=x[id];
		Y+=y[id];
	}
	tmp.pop_back();
	return ret%mod;
}
main()
{
	F[0]=1;
	for(int i=1;i<99;i++)F[i]=F[i-1]*i%mod;
	I[98]=power(F[98],mod-2);
	for(int i=98;i--;)I[i]=I[i+1]*(i+1)%mod;
	cin>>gx>>gy>>K;
	for(int i=0;i<K;i++)
	{
		cin>>x[i]>>y[i]>>n[i];
	}
	cout<<dfs(0,0,0)<<endl;
}
0