結果

問題 No.890 移調の限られた旋法
ユーザー kotatsugamekotatsugame
提出日時 2019-09-21 00:33:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 828 bytes
コンパイル時間 959 ms
コンパイル使用メモリ 77,380 KB
実行使用メモリ 19,972 KB
最終ジャッジ日時 2023-10-13 09:18:24
合計ジャッジ時間 2,910 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,424 KB
testcase_01 AC 2 ms
5,404 KB
testcase_02 AC 2 ms
5,452 KB
testcase_03 AC 2 ms
5,476 KB
testcase_04 AC 2 ms
5,420 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
5,524 KB
testcase_08 AC 3 ms
5,476 KB
testcase_09 AC 2 ms
5,452 KB
testcase_10 AC 2 ms
5,428 KB
testcase_11 AC 2 ms
5,676 KB
testcase_12 AC 2 ms
5,404 KB
testcase_13 AC 1 ms
4,352 KB
testcase_14 AC 39 ms
19,732 KB
testcase_15 AC 39 ms
19,796 KB
testcase_16 AC 39 ms
19,776 KB
testcase_17 AC 35 ms
19,736 KB
testcase_18 AC 35 ms
19,780 KB
testcase_19 AC 23 ms
15,628 KB
testcase_20 AC 15 ms
11,584 KB
testcase_21 AC 5 ms
5,956 KB
testcase_22 AC 31 ms
15,696 KB
testcase_23 AC 37 ms
19,716 KB
testcase_24 AC 23 ms
15,688 KB
testcase_25 AC 7 ms
6,456 KB
testcase_26 AC 37 ms
19,740 KB
testcase_27 AC 39 ms
19,724 KB
testcase_28 AC 26 ms
15,768 KB
testcase_29 AC 18 ms
11,556 KB
testcase_30 AC 36 ms
19,972 KB
testcase_31 AC 21 ms
11,660 KB
testcase_32 AC 34 ms
19,776 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 35 ms
19,868 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 F[a]*I[b]%mod*I[a-b]%mod;}
main()
{
	cin>>N>>K;
	if(N==K)
	{
		cout<<(N>1)<<endl;
		return 0;
	}
	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