結果

問題 No.644 G L C C D M
ユーザー e869120e869120
提出日時 2018-02-02 21:56:14
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 789 bytes
コンパイル時間 838 ms
コンパイル使用メモリ 80,960 KB
実行使用メモリ 4,680 KB
最終ジャッジ日時 2023-08-30 02:10:03
合計ジャッジ時間 2,271 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
4,408 KB
testcase_01 AC 10 ms
4,380 KB
testcase_02 AC 10 ms
4,468 KB
testcase_03 AC 9 ms
4,544 KB
testcase_04 AC 9 ms
4,384 KB
testcase_05 AC 10 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 9 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 10 ms
4,376 KB
testcase_10 AC 9 ms
4,468 KB
testcase_11 WA -
testcase_12 AC 10 ms
4,380 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 10 ms
4,380 KB
testcase_16 AC 10 ms
4,380 KB
testcase_17 AC 10 ms
4,500 KB
testcase_18 AC 12 ms
4,484 KB
testcase_19 AC 9 ms
4,376 KB
testcase_20 AC 10 ms
4,384 KB
testcase_21 AC 9 ms
4,596 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 12 ms
4,464 KB
testcase_26 AC 11 ms
4,464 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;
	long long R = p*p;
	for (int i = 2; i <= p; i++) {
		if (primes[i] == true) {
			long long G = p / i;
			R -= 1LL * G*G;
		}
	}
	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