結果
| 問題 |
No.644 G L C C D M
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-04-12 11:16:27 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 780 bytes |
| コンパイル時間 | 856 ms |
| コンパイル使用メモリ | 115,584 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-13 00:23:28 |
| 合計ジャッジ時間 | 1,511 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 WA * 2 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;
void main() {
immutable long MOD = 10^^9 + 7;
auto s = readln.split.map!(to!int);
auto N = s[0];
auto M = s[1];
if (M > N) {
writeln(0);
return;
}
auto cnt = new int[](N+1);
foreach (i; iota(M, N+1, M)) cnt[i] = 1;
long ans = N/M * (N/M - 1) % MOD;
for (int i = M+1; i <= N; ++i) {
if (cnt[i] == 0) continue;
ans -= N/i * (N/i - 1) % MOD * cnt[i] % MOD;
ans = (ans + MOD) % MOD;
for (int j = i + i; j <= N; j += i) cnt[j] -= cnt[i];
}
foreach (i; 1..N-1) ans = ans * i % MOD;
ans.writeln;
}