結果

問題 No.802 だいたい等差数列
ユーザー kotatsugamekotatsugame
提出日時 2020-03-12 02:11:03
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 666 bytes
コンパイル時間 588 ms
コンパイル使用メモリ 65,868 KB
実行使用メモリ 23,992 KB
最終ジャッジ日時 2023-08-10 04:56:06
合計ジャッジ時間 4,600 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
23,648 KB
testcase_01 AC 50 ms
23,640 KB
testcase_02 AC 51 ms
23,956 KB
testcase_03 AC 50 ms
23,804 KB
testcase_04 AC 50 ms
23,684 KB
testcase_05 AC 50 ms
23,700 KB
testcase_06 AC 50 ms
23,712 KB
testcase_07 AC 50 ms
23,752 KB
testcase_08 AC 50 ms
23,632 KB
testcase_09 AC 50 ms
23,652 KB
testcase_10 AC 52 ms
23,648 KB
testcase_11 AC 57 ms
23,636 KB
testcase_12 AC 56 ms
23,636 KB
testcase_13 AC 55 ms
23,684 KB
testcase_14 AC 59 ms
23,660 KB
testcase_15 AC 56 ms
23,808 KB
testcase_16 AC 58 ms
23,680 KB
testcase_17 AC 57 ms
23,988 KB
testcase_18 AC 55 ms
23,636 KB
testcase_19 AC 59 ms
23,636 KB
testcase_20 AC 68 ms
23,688 KB
testcase_21 AC 69 ms
23,992 KB
testcase_22 AC 57 ms
23,704 KB
testcase_23 AC 61 ms
23,636 KB
testcase_24 RE -
testcase_25 AC 50 ms
23,684 KB
testcase_26 AC 57 ms
23,772 KB
testcase_27 AC 56 ms
23,676 KB
testcase_28 AC 61 ms
23,712 KB
testcase_29 AC 70 ms
23,736 KB
testcase_30 AC 50 ms
23,672 KB
testcase_31 AC 50 ms
23,676 KB
testcase_32 AC 50 ms
23,732 KB
testcase_33 AC 50 ms
23,700 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:13:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   13 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
long mod=1e9+7;
int N,M,D1,D;
const int LIM=1301000;
long F[LIM],I[LIM];
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
long comb(long N,long K){return N<K||N<0||K<0?0L:F[N]*I[K]%mod*I[N-K]%mod;}
long H(long N,long K)
{
	return K==0?1L:comb(N+K-1,K);
}
main()
{
	F[0]=1;
	for(int i=1;i<LIM;i++)F[i]=F[i-1]*i%mod;
	I[LIM-1]=power(F[LIM-1],mod-2);
	for(int i=LIM-1;i--;)I[i]=I[i+1]*-~i%mod;
	cin>>N>>M>>D1>>D;
	M--;
	D-=D1;
	M-=(N-1)*D1;
	long ans=0;
	for(int i=0;i<N;i++)
	{
		long now=comb(N-1,i)*H(N+1,M-(long)i*(D+1))%mod;
		if(i%2==0)ans+=now;
		else ans-=now;
	}
	cout<<(ans%mod+mod)%mod<<endl;
}
0