結果

問題 No.890 移調の限られた旋法
ユーザー kotatsugamekotatsugame
提出日時 2019-09-21 00:21:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 785 bytes
コンパイル時間 741 ms
コンパイル使用メモリ 76,120 KB
実行使用メモリ 20,004 KB
最終ジャッジ日時 2023-10-13 09:11:47
合計ジャッジ時間 2,684 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,428 KB
testcase_01 AC 2 ms
5,480 KB
testcase_02 AC 2 ms
5,400 KB
testcase_03 AC 2 ms
5,456 KB
testcase_04 AC 2 ms
5,488 KB
testcase_05 AC 2 ms
5,408 KB
testcase_06 WA -
testcase_07 AC 2 ms
5,452 KB
testcase_08 AC 2 ms
5,396 KB
testcase_09 AC 2 ms
5,412 KB
testcase_10 AC 2 ms
5,464 KB
testcase_11 AC 2 ms
5,456 KB
testcase_12 AC 2 ms
5,400 KB
testcase_13 AC 39 ms
19,824 KB
testcase_14 AC 39 ms
19,724 KB
testcase_15 AC 39 ms
19,756 KB
testcase_16 AC 39 ms
19,728 KB
testcase_17 AC 36 ms
19,808 KB
testcase_18 AC 36 ms
19,844 KB
testcase_19 AC 22 ms
15,636 KB
testcase_20 AC 15 ms
11,536 KB
testcase_21 AC 5 ms
6,000 KB
testcase_22 AC 30 ms
15,684 KB
testcase_23 AC 37 ms
19,912 KB
testcase_24 AC 23 ms
15,632 KB
testcase_25 AC 7 ms
6,472 KB
testcase_26 AC 38 ms
19,744 KB
testcase_27 AC 38 ms
19,728 KB
testcase_28 AC 25 ms
15,756 KB
testcase_29 AC 18 ms
11,644 KB
testcase_30 AC 35 ms
19,784 KB
testcase_31 AC 21 ms
11,608 KB
testcase_32 AC 33 ms
19,840 KB
testcase_33 WA -
testcase_34 AC 35 ms
20,004 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:11:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   11 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N,K;
vector<int>A;
long mod=1e9+7,ans[1<<17];
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
long F[1<<20],I[1<<20];
long C(int a,int b){return a<b?0:F[a]*I[b]%mod*I[a-b]%mod;}
main()
{
	cin>>N>>K;
	F[0]=1;
	for(int i=1;i<=N;i++)F[i]=F[i-1]*i%mod;
	I[N]=power(F[N],mod-2);
	for(int i=N;i--;)I[i]=I[i+1]*(i+1)%mod;
	for(int i=2;i*i<=N;i++)
	{
		if(N%i==0)
		{
			A.push_back(i);
			if(i<N/i)A.push_back(N/i);
		}
	}
	sort(A.begin(),A.end());
	long ret=0;
	for(int i=0;i<A.size();i++)
	{
		int k=A[i];
		if(K%(N/k))continue;
		int x=K/(N/k);
		ans[i]=C(k,x);
		for(int j=0;j<i;j++)
		{
			if(A[i]%A[j]==0)(ans[i]+=mod-ans[j])%=mod;
		}
		(ret+=ans[i])%=mod;
	}
	cout<<ret<<endl;
}
0