結果

問題 No.443 GCD of Permutation
ユーザー miraxialmiraxial
提出日時 2016-11-11 23:37:45
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 501 bytes
コンパイル時間 62 ms
コンパイル使用メモリ 11,276 KB
実行使用メモリ 15,408 KB
最終ジャッジ日時 2023-08-16 19:50:45
合計ジャッジ時間 3,975 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 79 ms
15,296 KB
testcase_02 AC 78 ms
15,056 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 78 ms
15,300 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 81 ms
15,116 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 81 ms
15,104 KB
testcase_29 WA -
testcase_30 WA -
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 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*3
end
0