結果
| 問題 |
No.1611 Minimum Multiple with Double Divisors
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-11-17 11:05:32 |
| 言語 | Ruby (3.4.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 662 bytes |
| コンパイル時間 | 281 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 28,032 KB |
| 最終ジャッジ日時 | 2024-12-23 07:00:17 |
| 合計ジャッジ時間 | 51,538 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 28 TLE * 9 |
コンパイルメッセージ
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)}
i = 2
while not multiple?(n, f, prime_factor(i)) do
i += 1
end
ans << x * i
}
puts ans