結果
| 問題 | No.219 巨大数の概算 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-12-22 12:34:55 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 570 bytes |
| 記録 | |
| コンパイル時間 | 129 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 12,800 KB |
| 最終ジャッジ日時 | 2024-09-25 10:08:50 |
| 合計ジャッジ時間 | 22,120 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 1 WA * 50 |
コンパイルメッセージ
Main.rb:23: warning: assigned but unused variable - af Syntax OK
ソースコード
def pow(a, b)
x = 1
while b > 0
if b.odd?
x *= a
end
a *= a
b /= 2
a /= 1e18.to_i if a > 1e18
x /= 1e18.to_i if x > 1e18
end
return x
end
gets.to_i.times do
a,b = gets.split.map(&:to_i)
af = a.to_f
bf = b.to_f
#p af**b
#fmt = ("%.1e"%[af**b]).scan(/([0-9.]+)e\+(\d+)/)[0]
#puts "#{fmt[0][0]} #{fmt[0][2]} #{fmt[1].to_i}"
#p af**b
#p Math.log(af**b, 10)
s = pow(a,b).to_s
q = bf/Math.log(10, a)
puts "#{s[0]} #{s[1]} #{q.to_i}"
end