結果

問題 No.443 GCD of Permutation
ユーザー koyumeishikoyumeishi
提出日時 2016-11-11 23:53:33
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 581 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 11,308 KB
実行使用メモリ 23,876 KB
最終ジャッジ日時 2023-08-16 20:06:32
合計ジャッジ時間 23,330 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 777 ms
15,500 KB
testcase_01 AC 778 ms
15,424 KB
testcase_02 AC 778 ms
15,288 KB
testcase_03 AC 778 ms
15,276 KB
testcase_04 AC 77 ms
15,244 KB
testcase_05 AC 76 ms
15,292 KB
testcase_06 AC 776 ms
15,404 KB
testcase_07 AC 779 ms
15,480 KB
testcase_08 AC 778 ms
15,132 KB
testcase_09 AC 778 ms
15,364 KB
testcase_10 AC 77 ms
15,120 KB
testcase_11 AC 778 ms
15,484 KB
testcase_12 AC 777 ms
15,484 KB
testcase_13 AC 77 ms
15,128 KB
testcase_14 AC 785 ms
23,652 KB
testcase_15 AC 779 ms
18,192 KB
testcase_16 AC 99 ms
16,716 KB
testcase_17 AC 779 ms
17,268 KB
testcase_18 AC 156 ms
23,076 KB
testcase_19 AC 80 ms
15,944 KB
testcase_20 WA -
testcase_21 AC 781 ms
18,268 KB
testcase_22 AC 777 ms
15,560 KB
testcase_23 AC 780 ms
15,208 KB
testcase_24 AC 777 ms
15,480 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 784 ms
19,676 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 779 ms
23,876 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:24: warning: assigned but unused variable - i
Main.rb:25: warning: assigned but unused variable - j
Syntax OK

ソースコード

diff #

#sorry
def main
  s = gets.chomp

  x = Time.now()

  len = s.length

  if len == 1 then
    puts s
    return
  end
  g = s.to_i
  n = g

  while true 
    y = Time.now()
    if y-x > 0.700 then
      break
    end
    if g == 1 then
      break
    end
    for i in 0..10 do
      for j in 0...5 do
        a = rand(0...len)
        b = rand(0...len)
        u = (n % (10**(a+1)) / (10**a))
        v = (n % (10**(b+1)) / (10**b))

        n = n + ((v-u)*(10**a)) + ((u-v)*(10**b))
      end
      if g != n then
        g = g.gcd(n)
      end
    end
  end

  puts g
end

main()
0