結果
| 問題 |
No.443 GCD of Permutation
|
| コンテスト | |
| ユーザー |
yuruhiya
|
| 提出日時 | 2021-01-24 17:26:18 |
| 言語 | Crystal (1.14.0) |
| 結果 |
AC
|
| 実行時間 | 769 ms / 1,000 ms |
| コード長 | 351 bytes |
| コンパイル時間 | 13,517 ms |
| コンパイル使用メモリ | 297,976 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-21 07:50:21 |
| 合計ジャッジ時間 | 17,104 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 28 |
ソースコード
lib C
fun strtoll(s : UInt8*, p : UInt8**, b : Int32) : Int64
end
class String
def to_i64
C.strtoll(self, nil, 10)
end
end
require "big"
s = read_line
num = s.to_big_i
s = s.chars.map &.to_i
n = s.size
if s.count(s[0]) == n
puts s.join
exit
end
g = 0
s.each { |i|
s.each { |j|
g = g.gcd(9*(i - j)) if i > j
}
}
p num.gcd(g)
yuruhiya