結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 3 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 WA -
testcase_12 AC 2 ms
4,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 4 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 4 ms
4,380 KB
testcase_26 AC 3 ms
4,376 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[100009];

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)R -= 1LL*(p / i)*(p / i);
	}
	return R - 1;
}

int main() {
	for (int i = 2; i <= 100008; i++) primes[i] = true;
	for (int i = 2; i*i <= 100008; i++) {
		for (int j = i*i; j <= 100008; 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