結果

問題 No.443 GCD of Permutation
ユーザー miraxialmiraxial
提出日時 2016-11-11 23:09:29
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 514 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-05-04 03:03:58
合計ジャッジ時間 3,583 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
12,288 KB
testcase_01 AC 88 ms
12,160 KB
testcase_02 AC 76 ms
12,160 KB
testcase_03 AC 76 ms
12,032 KB
testcase_04 AC 76 ms
12,288 KB
testcase_05 AC 73 ms
12,288 KB
testcase_06 AC 78 ms
12,160 KB
testcase_07 AC 78 ms
12,160 KB
testcase_08 AC 77 ms
12,160 KB
testcase_09 AC 75 ms
12,032 KB
testcase_10 AC 79 ms
12,160 KB
testcase_11 WA -
testcase_12 AC 80 ms
12,160 KB
testcase_13 AC 75 ms
12,160 KB
testcase_14 AC 90 ms
12,416 KB
testcase_15 WA -
testcase_16 AC 77 ms
12,032 KB
testcase_17 AC 77 ms
12,160 KB
testcase_18 AC 83 ms
12,032 KB
testcase_19 AC 78 ms
12,288 KB
testcase_20 AC 79 ms
12,288 KB
testcase_21 AC 79 ms
12,160 KB
testcase_22 WA -
testcase_23 AC 76 ms
12,160 KB
testcase_24 WA -
testcase_25 AC 87 ms
12,416 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 81 ms
12,160 KB
testcase_29 WA -
testcase_30 AC 82 ms
12,288 KB
testcase_31 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

s=gets.chomp
c=0
n=s[0].to_i
b=8
j=true
nn=s[0].to_i
s.length.times do |i|
  g=s[i].to_i
  if g%2==0
    b=g if b>g && g!=0
  else
    b=1
  end
  if j && g%5==0
    j=true
  else
    j=false
  end
  if n!=-1 && n!=g
    n=-1
  end
  if nn!=-1 && g!=0 && n!=g
    nn=-1
  end
  c+=g
end
cc=1
loop do
  if c%3==0
    c/=3
    cc*=3
  else
    break
  end
end
j=j ? 5:1
if n!=-1
  puts s
elsif nn!=-1
  if nn==3 && nn==6
    puts nn*cc/3
  elsif nn==9
    puts nn*cc/9
  else
    puts nn
  end
else
  puts b*cc*j
end
0