結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,484 KB
testcase_01 AC 2 ms
5,672 KB
testcase_02 AC 2 ms
5,592 KB
testcase_03 AC 2 ms
5,460 KB
testcase_04 AC 2 ms
5,408 KB
testcase_05 WA -
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 2 ms
5,396 KB
testcase_08 AC 2 ms
5,392 KB
testcase_09 AC 2 ms
5,408 KB
testcase_10 AC 2 ms
5,412 KB
testcase_11 AC 2 ms
5,472 KB
testcase_12 AC 2 ms
5,424 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 39 ms
19,848 KB
testcase_15 AC 39 ms
19,788 KB
testcase_16 AC 39 ms
19,992 KB
testcase_17 AC 36 ms
19,988 KB
testcase_18 AC 36 ms
19,804 KB
testcase_19 AC 22 ms
15,636 KB
testcase_20 AC 15 ms
11,596 KB
testcase_21 AC 5 ms
6,000 KB
testcase_22 AC 30 ms
15,684 KB
testcase_23 AC 37 ms
19,804 KB
testcase_24 AC 22 ms
15,640 KB
testcase_25 AC 7 ms
6,452 KB
testcase_26 AC 37 ms
19,736 KB
testcase_27 AC 38 ms
19,716 KB
testcase_28 AC 26 ms
15,828 KB
testcase_29 AC 18 ms
11,800 KB
testcase_30 AC 35 ms
19,732 KB
testcase_31 AC 21 ms
11,588 KB
testcase_32 AC 34 ms
19,804 KB
testcase_33 AC 2 ms
4,352 KB
testcase_34 AC 34 ms
19,780 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<<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