結果

問題 No.644 G L C C D M
ユーザー square1001square1001
提出日時 2017-08-16 21:02:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 578 bytes
コンパイル時間 1,733 ms
コンパイル使用メモリ 162,940 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 14:17:02
合計ジャッジ時間 2,846 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int N, M, mobius[100009], mod = 1000000007;
long long solve(long long x) {
	fill(mobius, mobius + x + 1, 1);
	for(int i = 2; i <= x; i++) {
		for(int j = i; j <= x; j += i) mobius[j] *= -1;
		if(i * i <= x) for(int j = i * i; j <= x; j += i * i) mobius[j] = 0;
	}
	long long ret = 0;
	for(int i = 1; i <= x; i++) ret += 1LL * mobius[i] * (x / i) * (x / i);
	return ret;
}
int main() {
	cin >> N >> M;
	int ret = (solve(N / M) - 1) % mod;
	for(int i = 1; i <= N - 2; i++) ret = 1LL * ret * i % mod;
	cout << ret << endl;
	return 0;
}
0