結果

問題 No.2379 Burnside's Theorem
ユーザー Lisp_CoderLisp_Coder
提出日時 2023-08-04 01:30:02
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 627 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 7,296 KB
実行使用メモリ 18,864 KB
最終ジャッジ日時 2024-04-22 00:04:18
合計ジャッジ時間 5,689 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
12,416 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 96 ms
12,544 KB
testcase_09 WA -
testcase_10 AC 101 ms
12,672 KB
testcase_11 WA -
testcase_12 AC 96 ms
12,544 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 94 ms
12,544 KB
testcase_18 AC 333 ms
18,836 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 345 ms
18,864 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def gi
  gets.chomp.to_i
end

def gm
  gets.chomp.split.map(&:to_i)
end

def gc
  gets.chomp
end

def gs
  gets.chomp.split
end

require 'prime'

def factorize(n)
  factors = []
  primes = Prime.each(Math.sqrt(n).to_i)
  primes.each do |p|
    while n % p == 0
      factors << p
      n /= p
    end
  end
  factors << n if n > 1
  factors
end

def check_if_solvable(n)
  factors = factorize(n)
  return false if factors.empty?
  p = factors.uniq[0]
  q = factors.uniq[1]
  a = factors.count(p)
  b = factors.count(q)
  return p && q && a >= 0 && b >= 0
end

N = gi

if check_if_solvable(N)
  puts "Yes"
else
  puts "No"
end

0