結果

問題 No.644 G L C C D M
ユーザー kurenai3110
提出日時 2018-02-02 22:49:57
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 462 bytes
コンパイル時間 775 ms
コンパイル使用メモリ 59,516 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-31 07:59:16
合計ジャッジ時間 1,884 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

#define MOD (int)(1e9+7)

int solve(int N,int M) {
	long long cnt = N / M;

	long long ans = cnt*(cnt - 1);
	for (int i = 2; i <= cnt; i++) {
		ans -= (cnt / i) * (cnt / i - 1);
	}
	ans %= MOD;
	for (int i = N - 2; i >= 1; i--) {
		ans *= i;
		ans %= MOD;
	}
	return ans;
}

int main()
{
	int N, M; cin >> N >> M;

	cout << solve(N, M) << endl;

    return 0;
}

0