結果
問題 |
No.1611 Minimum Multiple with Double Divisors
|
ユーザー |
|
提出日時 | 2021-11-17 11:04:33 |
言語 | Ruby (3.4.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 686 bytes |
コンパイル時間 | 146 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 27,392 KB |
最終ジャッジ日時 | 2024-12-23 06:56:44 |
合計ジャッジ時間 | 58,014 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 2 |
other | WA * 19 TLE * 18 |
コンパイルメッセージ
Syntax OK
ソースコード
def prime_factor(n) res = Hash.new(0) i = 2 while i * i <= n do while n % i == 0 do res[i] += 1 n /= i end i += 1 end res[n] += 1 if n != 1 res end def prime?(n) i = 2 while i * i <= n do return false if n % i == 0 i += 1 end n != 1 end def multiple?(n, f0, f1) y = n f1.each{|k, v| if f0.include?(k) z = f0[k] y = y / (z+1) * (z+v+1) else y *= v + 1 end } n * 2 == y end T = gets.to_i X = [] T.times { X << gets.to_i } ans = [] X.each {|x| f = prime_factor(x) n = f.values.inject(1) {|product, i| product * (i + 1)} print n, ", ", f, "\n" i = 2 while not multiple?(n, f, prime_factor(i)) do i += 1 end ans << x * i } puts ans