結果

問題 No.443 GCD of Permutation
ユーザー miraxialmiraxial
提出日時 2016-11-11 23:51:43
言語 Ruby
(3.3.0)
結果
RE  
実行時間 -
コード長 519 bytes
コンパイル時間 144 ms
コンパイル使用メモリ 11,464 KB
実行使用メモリ 15,392 KB
最終ジャッジ日時 2023-08-16 20:02:49
合計ジャッジ時間 3,590 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 70 ms
15,088 KB
testcase_02 RE -
testcase_03 AC 66 ms
15,032 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 71 ms
15,144 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 68 ms
15,180 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 70 ms
15,272 KB
testcase_15 AC 68 ms
15,340 KB
testcase_16 RE -
testcase_17 AC 69 ms
15,188 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 AC 72 ms
15,144 KB
testcase_31 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 b!=1 && g%2==0
    b=(b.gcd g) if 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
if c%9==0
  c=9
elsif c%3==0
  c=3
else
  c=1
end
j=j ? 5:1
if n!=-1
  puts s
elsif nn!=-1
  if nn==3 && nn==6
    puts nn*c/3
  elsif nn==9
    puts nn*c/9
  else
    puts nn
  end
else
  puts b*c*j
end
if b%2==1
raise
end
0