結果

問題 No.443 GCD of Permutation
ユーザー yuruhiyayuruhiya
提出日時 2021-01-24 17:22:47
言語 Crystal
(1.11.2)
結果
TLE  
実行時間 -
コード長 362 bytes
コンパイル時間 16,721 ms
コンパイル使用メモリ 261,856 KB
実行使用メモリ 483,400 KB
最終ジャッジ日時 2023-09-13 13:21:25
合計ジャッジ時間 19,776 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 3 ms
4,384 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 3 ms
4,436 KB
testcase_04 AC 2 ms
4,508 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 3 ms
4,456 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 3 ms
4,404 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 3 ms
4,384 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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