結果

問題 No.443 GCD of Permutation
コンテスト
ユーザー yuruhiya
提出日時 2021-01-24 17:22:47
言語 Crystal
(1.19.1)
コンパイル:
crystal build -Donline_judge -o a.out --release --no-debug _filename_
実行:
./a.out
結果
MLE  
実行時間 -
コード長 362 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 9,729 ms
コンパイル使用メモリ 345,452 KB
実行使用メモリ 1,302,032 KB
最終ジャッジ日時 2026-03-21 08:50:11
合計ジャッジ時間 34,814 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 MLE * 1
other AC * 7 RE * 6 TLE * 10 MLE * 5
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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
n = s.size
if s.count(s[0]) == n
  puts s
  exit
end

p (0...n).to_a.combinations(2).map { |(i, j)|
  ("#{s[i]}#{s[j]}".to_i - "#{s[j]}#{s[i]}".to_i).abs
}.reduce(0) { |i, j| i.gcd(j) }.gcd(s.to_i)
0