結果
問題 |
No.443 GCD of Permutation
|
ユーザー |
![]() |
提出日時 | 2021-01-24 17:29:59 |
言語 | Crystal (1.14.0) |
結果 |
AC
|
実行時間 | 322 ms / 1,000 ms |
コード長 | 361 bytes |
コンパイル時間 | 12,006 ms |
コンパイル使用メモリ | 301,452 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-30 22:13:40 |
合計ジャッジ時間 | 14,427 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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 a = s.chars.map(&.to_i).sort n = a.size g = 0 (0...n).each { |i| (i + 1...n).each { |j| g = g.gcd(9*(a[j] - a[i])) if a[j] != a[i] } } if g == 0 puts s else puts s.to_big_i.gcd(g) end