結果
| 問題 |
No.2379 Burnside's Theorem
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-04 01:30:02 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 627 bytes |
| コンパイル時間 | 217 ms |
| コンパイル使用メモリ | 7,296 KB |
| 実行使用メモリ | 18,756 KB |
| 最終ジャッジ日時 | 2024-10-13 22:35:16 |
| 合計ジャッジ時間 | 5,378 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 3 |
| other | AC * 6 WA * 14 |
コンパイルメッセージ
Syntax OK
ソースコード
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