結果

問題 No.1556 Power Equality
ユーザー simansiman
提出日時 2021-06-26 02:38:06
言語 Ruby
(3.3.0)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 304 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 11,496 KB
実行使用メモリ 15,400 KB
最終ジャッジ日時 2023-09-07 15:54:51
合計ジャッジ時間 2,586 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
15,324 KB
testcase_01 AC 94 ms
15,168 KB
testcase_02 AC 91 ms
15,396 KB
testcase_03 AC 93 ms
15,252 KB
testcase_04 AC 93 ms
15,212 KB
testcase_05 AC 93 ms
15,348 KB
testcase_06 AC 94 ms
15,228 KB
testcase_07 AC 93 ms
15,156 KB
testcase_08 AC 94 ms
15,304 KB
testcase_09 AC 94 ms
15,400 KB
testcase_10 AC 93 ms
15,364 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require 'prime'

A, B = gets.split.map(&:to_i).sort

if A == 1
  if B == 1
    puts 'Yes'
  else
    puts 'No'
  end

  exit
end

if B % A != 0
  puts 'No'
  exit
end

a = A
b = B
c = 0

while b > 1 && b >= a && b % a == 0
  b /= a
  c += 1
end

if b == 1 && A * c == B
  puts 'Yes'
else
  puts 'No'
end
0