結果

問題 No.644 G L C C D M
ユーザー square1001square1001
提出日時 2017-08-16 20:51:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 366 bytes
コンパイル時間 1,564 ms
コンパイル使用メモリ 164,104 KB
実行使用メモリ 10,268 KB
最終ジャッジ日時 2024-04-21 14:16:50
合計ジャッジ時間 7,956 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,320 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 10 ms
5,376 KB
testcase_09 AC 22 ms
5,376 KB
testcase_10 AC 43 ms
5,376 KB
testcase_11 AC 519 ms
5,376 KB
testcase_12 AC 1,861 ms
6,944 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int N, M, mod = 1000000007;
int main() {
	cin >> N >> M;
	int ret = 0;
	for(int i = 1; i <= N; i++) {
		for(int j = 1; j < i; j++) {
			if(i != j && __gcd(i, j) == M) {
				ret += 2;
				if(ret >= mod) ret -= mod;
			}
		}
	}
	for(int i = 1; i <= N - 2; i++) ret = 1LL * ret * i % mod;
	cout << ret << endl;
	return 0;
}
0