結果

問題 No.443 GCD of Permutation
ユーザー yuruhiyayuruhiya
提出日時 2021-01-24 17:26:18
言語 Crystal
(1.11.2)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 351 bytes
コンパイル時間 12,193 ms
コンパイル使用メモリ 293,476 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 06:40:43
合計ジャッジ時間 15,831 ms
ジャッジサーバーID
(参考情報)
judge9 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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
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

g = 0
s.each { |i|
  s.each { |j|
    g = g.gcd(9*(i - j)) if i > j
  }
}

p num.gcd(g)
0