結果
問題 |
No.14 最小公倍数ソート
|
ユーザー |
|
提出日時 | 2021-01-11 11:23:19 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 642 bytes |
コンパイル時間 | 130 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 22,784 KB |
最終ジャッジ日時 | 2024-11-21 08:56:32 |
合計ジャッジ時間 | 99,638 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 4 OLE * 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] print('a[{}]:{},a[{}]:{},lcm:{}'.format(i, a[i], j, a[j], lcm)) if(low_value > lcm): low_value = lcm idx = j temp = a[i + 1] a[i + 1] = a[idx] a[idx] = temp print(' '.join(map(str,a)))