結果
問題 | No.644 G L C C D M |
ユーザー | uafr_cs |
提出日時 | 2018-02-02 22:28:19 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 812 bytes |
コンパイル時間 | 1,989 ms |
コンパイル使用メモリ | 71,692 KB |
実行使用メモリ | 60,636 KB |
最終ジャッジ日時 | 2023-08-30 02:17:02 |
合計ジャッジ時間 | 8,544 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 123 ms
60,636 KB |
testcase_01 | AC | 121 ms
55,940 KB |
testcase_02 | AC | 122 ms
55,812 KB |
testcase_03 | AC | 125 ms
55,520 KB |
testcase_04 | AC | 122 ms
55,864 KB |
testcase_05 | AC | 122 ms
55,464 KB |
testcase_06 | AC | 123 ms
55,556 KB |
testcase_07 | AC | 126 ms
56,036 KB |
testcase_08 | AC | 150 ms
55,756 KB |
testcase_09 | AC | 171 ms
56,004 KB |
testcase_10 | AC | 210 ms
55,728 KB |
testcase_11 | AC | 1,107 ms
55,984 KB |
testcase_12 | TLE | - |
testcase_13 | -- | - |
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 | -- | - |
ソースコード
import java.util.Arrays; import java.util.LinkedList; import java.util.Scanner; public class Main { public static long gcd(long a, long b){ return b == 0 ? a : gcd(b, a % b); } public static long lcm(long a, long b){ return a / gcd(a, b) * b; } public static final long MOD = 1000000007; public static void main(String[] args) { Scanner sc = new Scanner(System.in); final long N = sc.nextLong(); final long M = sc.nextLong(); long other_fact = 1; for(int i = 1; i <= (N - 2); i++){ other_fact *= i; other_fact %= MOD; } long answer = 0; for(int fst = 1; fst <= N; fst++){ for(int snd = fst + 1; snd <= N; snd++){ if(gcd(fst, snd) != M){ continue; } answer += (other_fact * 2) % MOD; answer %= MOD; } } System.out.println(answer); } }