結果

問題 No.3474 Concat Decimal
コンテスト
ユーザー LyricalMaestro
提出日時 2026-03-21 18:28:21
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 236 ms / 2,000 ms
コード長 1,069 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,051 ms
コンパイル使用メモリ 85,096 KB
実行使用メモリ 113,336 KB
最終ジャッジ日時 2026-03-21 18:28:28
合計ジャッジ時間 5,817 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# https://yukicoder.me/problems/no/3474


def calc_gcd(A, B):
    """
    正の整数A, Bの最大公約数を計算する
    """
    a = max(A, B)
    b = min(A, B)
    while a % b > 0:
        c = a % b
        a = b
        b = c
    return b

def solve(N, A):
    lcm = 1
    for j in range(1, N):
        a = A[j]

        a_str = str(a)
        array = []
        for k in reversed(a_str):
            if len(array) == 0 and k == "0":
                continue
            array.append(k)
        if len(array) == 0:
            continue

        array.reverse()
        a0 = int("".join(array))

        l = len(str(a0))
        p = 10 ** l

        x = calc_gcd(p, int(a0))
        p_ = p // x

        x_ = calc_gcd(p_, lcm)
        lcm = (lcm // x_) * p_

    return lcm



def main():
    T = int(input())
    answers = []
    for _ in range(T):
        N = int(input())
        A = list(map(int, input().split()))
        ans = solve(N, A)
        answers.append(ans)

    for ans in answers:
        print(ans)







if __name__ == "__main__":
    main()
0