結果

問題 No.890 移調の限られた旋法
ユーザー polylogKpolylogK
提出日時 2019-09-20 22:09:13
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,360 bytes
コンパイル時間 1,439 ms
コンパイル使用メモリ 167,312 KB
実行使用メモリ 19,064 KB
最終ジャッジ日時 2023-10-12 19:28:10
合計ジャッジ時間 2,858 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 1 ms
4,352 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 WA -
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
4,348 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 2 ms
4,352 KB
testcase_22 WA -
testcase_23 AC 1 ms
4,348 KB
testcase_24 WA -
testcase_25 AC 1 ms
4,348 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 1 ms
4,352 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, k; scanf("%d%d", &n, &k);
	if((n ^ k) & 1) {
		printf("0\n");
		return 0;
	}

	const int MOD = 1e9 + 7;
	auto pow = [&](i64 x, i64 n) {
		i64 ret = 1;
		while(n) {
			if(n & 1) (ret *= x) %= MOD;
			(x *= x) %= MOD;
			n >>= 1;
		}
		return ret;
	};
	auto inv = [&](i64 n) {
		return pow(n, MOD - 2);
	};
	std::vector<i64> fact(n + 1, 1);
	for(i64 i = 0; i < n; i++) fact[i + 1] = fact[i] * (i + 1);
	auto comb = [&](int n, int r) {
		if(n < r) return 0LL;
	
		return fact[n] * inv(fact[r]) % MOD * inv(fact[n - r]) % MOD;
	};
	
	i64 ans = 0;
	std::vector<i64> latte(n, 0);
	for(int i = 1; i < n; i++) {
		if(n % i) continue;
	
		int cnt = n / i;
		if(k % cnt) continue;
		int loop = k / cnt;

		(ans += comb(i, loop)) %= MOD;
		(latte[i] = comb(i, loop)) %= MOD;
	
		for(int j = 2; j * j <= i; j++) {
			if(i % j) continue;
			
			ans = (ans - latte[j] + MOD) % MOD;
			if(j != i / j) ans = (ans - latte[i / j] + MOD) % MOD;
		}
	}
	printf("%lld\n", ans);
	return 0;
}
0