結果

問題 No.644 G L C C D M
ユーザー e869120e869120
提出日時 2018-02-02 22:02:47
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 965 bytes
コンパイル時間 722 ms
コンパイル使用メモリ 81,348 KB
実行使用メモリ 4,560 KB
最終ジャッジ日時 2023-08-30 02:11:01
合計ジャッジ時間 2,254 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
4,376 KB
testcase_01 AC 10 ms
4,380 KB
testcase_02 AC 9 ms
4,380 KB
testcase_03 AC 9 ms
4,376 KB
testcase_04 AC 10 ms
4,380 KB
testcase_05 AC 9 ms
4,376 KB
testcase_06 AC 9 ms
4,404 KB
testcase_07 AC 9 ms
4,400 KB
testcase_08 AC 10 ms
4,468 KB
testcase_09 AC 10 ms
4,380 KB
testcase_10 AC 9 ms
4,380 KB
testcase_11 AC 9 ms
4,376 KB
testcase_12 AC 9 ms
4,380 KB
testcase_13 AC 13 ms
4,380 KB
testcase_14 AC 10 ms
4,376 KB
testcase_15 AC 9 ms
4,376 KB
testcase_16 AC 9 ms
4,504 KB
testcase_17 AC 9 ms
4,376 KB
testcase_18 AC 11 ms
4,384 KB
testcase_19 AC 10 ms
4,560 KB
testcase_20 AC 9 ms
4,404 KB
testcase_21 AC 10 ms
4,376 KB
testcase_22 AC 98 ms
4,376 KB
testcase_23 AC 45 ms
4,556 KB
testcase_24 AC 31 ms
4,560 KB
testcase_25 AC 12 ms
4,380 KB
testcase_26 AC 11 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <functional>
#include <map>
using namespace std;

long long n, m, mod = 1000000007; bool primes[1000009];

long long euler_phi(long long p) {
	long long r = p;
	for (int i = 2; i * i <= p; i++) {
		if (p % i == 0) r = 1LL * r * (i - 1) / i;
		while (p % i == 0) p /= i;
	}
	if (p != 1) r = 1LL * r * (p - 1) / p;
	return r;
}

long long prime(long long p) {
	if (p == 0) return 0;
	long long R = 0;
	for (int i = 1; i <= p; i++) {
		R += euler_phi(i);
	}
	R--;
	R *= 2;
	return R;
}

int main() {
	for (int i = 2; i <= 1000008; i++) primes[i] = true;
	for (int i = 2; i*i <= 1000008; i++) {
		for (int j = i*i; j <= 1000008; j += i) primes[j] = false;
	}
	cin >> n >> m;
	long long G = prime(n / m);
	long long ret = 1;
	for (int i = 1; i <= n - 2; i++) { ret *= i; ret %= mod; }
	ret *= (G % mod); ret %= mod;
	cout << ret << endl;
	return 0;
}
0