結果

問題 No.443 GCD of Permutation
ユーザー koyumeishikoyumeishi
提出日時 2016-11-11 22:51:03
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 443 bytes
コンパイル時間 351 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 35,328 KB
最終ジャッジ日時 2024-05-04 02:51:50
合計ジャッジ時間 20,502 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 780 ms
12,416 KB
testcase_01 AC 774 ms
12,416 KB
testcase_02 AC 776 ms
12,160 KB
testcase_03 AC 776 ms
12,544 KB
testcase_04 AC 77 ms
12,288 KB
testcase_05 AC 76 ms
12,416 KB
testcase_06 AC 775 ms
12,416 KB
testcase_07 AC 776 ms
12,288 KB
testcase_08 AC 782 ms
12,416 KB
testcase_09 AC 774 ms
12,288 KB
testcase_10 AC 76 ms
12,288 KB
testcase_11 AC 776 ms
12,288 KB
testcase_12 AC 781 ms
12,160 KB
testcase_13 AC 80 ms
12,416 KB
testcase_14 AC 781 ms
17,664 KB
testcase_15 AC 776 ms
16,512 KB
testcase_16 AC 101 ms
12,928 KB
testcase_17 AC 783 ms
13,824 KB
testcase_18 WA -
testcase_19 AC 82 ms
12,672 KB
testcase_20 RE -
testcase_21 AC 781 ms
17,024 KB
testcase_22 AC 777 ms
12,416 KB
testcase_23 AC 774 ms
12,288 KB
testcase_24 AC 778 ms
12,288 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 784 ms
14,976 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:24: warning: assigned but unused variable - i
Syntax OK

ソースコード

diff #

#sorry

s = gets.chomp

x = Time.now()

def gcd(a,b)
  if b!=0 then
    return gcd(b, a%b)
  else
    return a
  end
end

len = s.length
g = s.to_i
n = g

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

    n = n + (v-u)*(10**a) + (u-v)*(10**b)
    g = gcd(g, n)
  end
  if g == 1 then
    break
  end
end

puts g
0