結果

問題 No.644 G L C C D M
ユーザー kurenai3110kurenai3110
提出日時 2018-02-02 23:11:45
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 485 bytes
コンパイル時間 905 ms
コンパイル使用メモリ 61,140 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 02:27:15
合計ジャッジ時間 1,531 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,380 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,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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;
	if (cnt < 2)return 0;
	long long ans = 2*(cnt-1);
	for (int i = 2; i <= cnt; i++) {
		ans += 2*( (cnt - i) - (cnt - i) / i);
	}
	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