結果
| 問題 | No.443 GCD of Permutation | 
| コンテスト | |
| ユーザー |  yuruhiya | 
| 提出日時 | 2021-01-24 17:24:41 | 
| 言語 | Crystal (1.14.0) | 
| 結果 | 
                                MLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 373 bytes | 
| コンパイル時間 | 11,734 ms | 
| コンパイル使用メモリ | 299,784 KB | 
| 実行使用メモリ | 813,348 KB | 
| 最終ジャッジ日時 | 2024-06-30 22:14:35 | 
| 合計ジャッジ時間 | 15,468 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 14 MLE * 1 -- * 13 | 
ソースコード
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
p num.gcd (0...n).to_a.combinations(2).map { |(i, j)|
  9 * (s[i] - s[j]).abs
}.reduce(0) { |i, j| i.gcd(j) }
            
            
            
        