結果

問題 No.443 GCD of Permutation
ユーザー yuruhiyayuruhiya
提出日時 2021-01-24 17:34:57
言語 Crystal
(1.11.2)
結果
AC  
実行時間 4 ms / 1,000 ms
コード長 332 bytes
コンパイル時間 18,076 ms
コンパイル使用メモリ 264,512 KB
実行使用メモリ 5,172 KB
最終ジャッジ日時 2023-09-13 13:22:59
合計ジャッジ時間 19,600 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,824 KB
testcase_01 AC 3 ms
4,584 KB
testcase_02 AC 3 ms
4,764 KB
testcase_03 AC 3 ms
4,840 KB
testcase_04 AC 3 ms
4,820 KB
testcase_05 AC 2 ms
4,620 KB
testcase_06 AC 3 ms
4,756 KB
testcase_07 AC 3 ms
4,932 KB
testcase_08 AC 3 ms
4,792 KB
testcase_09 AC 3 ms
4,760 KB
testcase_10 AC 3 ms
4,788 KB
testcase_11 AC 3 ms
4,764 KB
testcase_12 AC 3 ms
4,884 KB
testcase_13 AC 3 ms
4,804 KB
testcase_14 AC 3 ms
4,592 KB
testcase_15 AC 3 ms
4,892 KB
testcase_16 AC 3 ms
4,796 KB
testcase_17 AC 3 ms
4,968 KB
testcase_18 AC 4 ms
5,172 KB
testcase_19 AC 3 ms
4,856 KB
testcase_20 AC 3 ms
4,976 KB
testcase_21 AC 3 ms
4,996 KB
testcase_22 AC 3 ms
4,860 KB
testcase_23 AC 3 ms
4,800 KB
testcase_24 AC 2 ms
4,888 KB
testcase_25 AC 3 ms
5,052 KB
testcase_26 AC 3 ms
5,088 KB
testcase_27 AC 3 ms
4,984 KB
testcase_28 AC 3 ms
5,132 KB
testcase_29 AC 3 ms
5,052 KB
testcase_30 AC 3 ms
5,120 KB
testcase_31 AC 4 ms
5,100 KB
権限があれば一括ダウンロードができます

ソースコード

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
g = s.chars.map(&.to_i).uniq.combinations(2).map { |(i, j)|
  9 * (i - j).abs
}.reduce(0) { |acc, x| acc.gcd(x) }

if g == 0
  puts s
else
  puts s.to_big_i.gcd(g)
end
0