結果

問題 No.644 G L C C D M
ユーザー e869120e869120
提出日時 2018-02-02 21:55:32
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 950 bytes
コンパイル時間 747 ms
コンパイル使用メモリ 81,144 KB
実行使用メモリ 4,672 KB
最終ジャッジ日時 2023-08-30 02:09:45
合計ジャッジ時間 2,254 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
4,672 KB
testcase_01 AC 9 ms
4,668 KB
testcase_02 AC 9 ms
4,380 KB
testcase_03 AC 9 ms
4,384 KB
testcase_04 AC 9 ms
4,396 KB
testcase_05 AC 9 ms
4,472 KB
testcase_06 AC 9 ms
4,416 KB
testcase_07 AC 9 ms
4,508 KB
testcase_08 AC 9 ms
4,400 KB
testcase_09 AC 9 ms
4,380 KB
testcase_10 AC 9 ms
4,400 KB
testcase_11 AC 64 ms
4,408 KB
testcase_12 AC 10 ms
4,500 KB
testcase_13 WA -
testcase_14 AC 24 ms
4,376 KB
testcase_15 AC 9 ms
4,396 KB
testcase_16 AC 9 ms
4,380 KB
testcase_17 AC 9 ms
4,416 KB
testcase_18 AC 11 ms
4,540 KB
testcase_19 AC 10 ms
4,416 KB
testcase_20 AC 10 ms
4,380 KB
testcase_21 AC 9 ms
4,380 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 11 ms
4,380 KB
testcase_26 AC 11 ms
4,396 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 prime(long long p) {
	if (p == 0) return 0;
	if (p <= 2500) {
		long long R = 0;
		for (int i = 1; i <= p; i++) {
			for (int j = 1; j <= p; j++) {
				if (i == j) continue;
				if (__gcd(i, j) == 1) R++;
			}
		}
		return R;
	}
	long long R = p*p;
	for (int i = 2; i <= p; i++) {
		if (primes[i] == true)R -= 1LL*(p / i)*(p / i);
	}
	return R - 1;
}

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