結果

問題 No.802 だいたい等差数列
ユーザー kotatsugamekotatsugame
提出日時 2020-03-12 02:09:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 656 bytes
コンパイル時間 591 ms
コンパイル使用メモリ 65,852 KB
実行使用メモリ 23,848 KB
最終ジャッジ日時 2024-04-27 22:15:22
合計ジャッジ時間 7,848 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
23,784 KB
testcase_01 AC 50 ms
23,840 KB
testcase_02 AC 49 ms
23,788 KB
testcase_03 AC 50 ms
23,812 KB
testcase_04 AC 49 ms
23,832 KB
testcase_05 AC 49 ms
23,740 KB
testcase_06 AC 49 ms
23,756 KB
testcase_07 AC 49 ms
23,736 KB
testcase_08 AC 50 ms
23,812 KB
testcase_09 AC 50 ms
23,788 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 57 ms
23,616 KB
testcase_15 AC 56 ms
23,760 KB
testcase_16 AC 58 ms
23,624 KB
testcase_17 AC 57 ms
23,808 KB
testcase_18 AC 55 ms
23,736 KB
testcase_19 AC 61 ms
23,792 KB
testcase_20 AC 68 ms
23,744 KB
testcase_21 AC 68 ms
23,756 KB
testcase_22 RE -
testcase_23 AC 60 ms
23,840 KB
testcase_24 RE -
testcase_25 AC 50 ms
23,656 KB
testcase_26 AC 56 ms
23,832 KB
testcase_27 RE -
testcase_28 AC 61 ms
23,748 KB
testcase_29 AC 68 ms
23,620 KB
testcase_30 AC 50 ms
23,624 KB
testcase_31 AC 49 ms
23,708 KB
testcase_32 AC 50 ms
23,748 KB
testcase_33 AC 50 ms
23,848 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:13:1: warning: ISO C++ forbids declaration of 'main' with no type [-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(int N,int K){return N<K||N<0||K<0?0L:F[N]*I[K]%mod*I[N-K]%mod;}
long H(int N,int 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-i*(D+1))%mod;
		if(i%2==0)ans+=now;
		else ans-=now;
	}
	cout<<(ans%mod+mod)%mod<<endl;
}
0