結果
| 問題 |
No.443 GCD of Permutation
|
| コンテスト | |
| ユーザー |
はむ吉🐹
|
| 提出日時 | 2016-11-11 22:58:04 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 482 bytes |
| コンパイル時間 | 241 ms |
| コンパイル使用メモリ | 82,600 KB |
| 実行使用メモリ | 88,960 KB |
| 最終ジャッジ日時 | 2024-11-25 09:14:03 |
| 合計ジャッジ時間 | 5,896 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 4 |
| other | RE * 28 |
ソースコード
#!/usr/bin/env pypy3
import fractions
import functools
import itertools
def generate_all_swaps(n):
xs = list(str(n))
m = len(xs)
yield n
for i, j in itertools.combinations(range(m), 2):
xs[i], xs[j] = xs[j], xs[i]
yield int("".join(xs))
xs[i], xs[j] = xs[j], xs[i]
def compute(n):
return functools.reduce(fractions.gcd, generate_all_swaps(n), n)
def main():
print(compute(int(input())))
if __name__ == '__main__':
main()
はむ吉🐹