結果

問題 No.1158 GCD Products easy
ユーザー lloyzlloyz
提出日時 2022-07-05 01:18:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 571 ms / 2,000 ms
コード長 332 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 10,520 KB
実行使用メモリ 8,900 KB
最終ジャッジ日時 2023-08-21 11:44:54
合計ジャッジ時間 2,593 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
8,784 KB
testcase_01 AC 20 ms
8,776 KB
testcase_02 AC 19 ms
8,676 KB
testcase_03 AC 19 ms
8,660 KB
testcase_04 AC 19 ms
8,812 KB
testcase_05 AC 19 ms
8,728 KB
testcase_06 AC 19 ms
8,660 KB
testcase_07 AC 37 ms
8,616 KB
testcase_08 AC 19 ms
8,784 KB
testcase_09 AC 19 ms
8,696 KB
testcase_10 AC 19 ms
8,856 KB
testcase_11 AC 19 ms
8,660 KB
testcase_12 AC 21 ms
8,792 KB
testcase_13 AC 19 ms
8,780 KB
testcase_14 AC 20 ms
8,784 KB
testcase_15 AC 19 ms
8,732 KB
testcase_16 AC 19 ms
8,824 KB
testcase_17 AC 20 ms
8,592 KB
testcase_18 AC 19 ms
8,900 KB
testcase_19 AC 19 ms
8,832 KB
testcase_20 AC 20 ms
8,832 KB
testcase_21 AC 19 ms
8,832 KB
testcase_22 AC 19 ms
8,780 KB
testcase_23 AC 19 ms
8,832 KB
testcase_24 AC 29 ms
8,800 KB
testcase_25 AC 19 ms
8,708 KB
testcase_26 AC 571 ms
8,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
from functools import reduce

a, b, n = map(int, input().split())
mod = 10**9 + 7

def bfs(L, idx):
    if idx == n:
        return reduce(gcd, L)
    ans = 1
    for i in range(a, b + 1):
        L[idx] = i
        ans *= bfs(L, idx + 1)
        ans %= mod
    return ans

print(bfs([0 for _ in range(n)], 0))
0