結果
問題 |
No.14 最小公倍数ソート
|
ユーザー |
|
提出日時 | 2021-01-11 11:10:15 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 601 bytes |
コンパイル時間 | 143 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 22,528 KB |
最終ジャッジ日時 | 2024-11-21 08:54:39 |
合計ジャッジ時間 | 98,106 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 1 WA * 3 TLE * 16 |
ソースコード
def gdc(a, b): if b == 0: return a else: return gdc(b, a % b) if __name__ == '__main__': N = int(input()) a = list(map(int, input().split())) for i in range(N - 1): idx = 0 low_value = 999999 for j in range(i + 1, N): d = gdc(a[i], a[j]) lcm = a[i] / d * a[j] if(low_value >= lcm): low_value = lcm if a[j] < a[idx]: idx = j temp = a[i + 1] a[i + 1] = a[idx] a[idx] = temp print(' '.join(map(str,a)))