結果
| 問題 | No.219 巨大数の概算 |
| コンテスト | |
| ユーザー |
小指が強い人
|
| 提出日時 | 2015-11-16 22:50:50 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 705 bytes |
| 記録 | |
| コンパイル時間 | 203 ms |
| コンパイル使用メモリ | 7,296 KB |
| 実行使用メモリ | 12,672 KB |
| 最終ジャッジ日時 | 2024-09-13 15:42:31 |
| 合計ジャッジ時間 | 19,414 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 2 WA * 49 |
コンパイルメッセージ
Main.rb:7: warning: assigned but unused variable - c Main.rb:12: warning: assigned but unused variable - qc Syntax OK
ソースコード
n = gets.to_i
m = 9
lim = 10 ** m
n.times do
str = gets.split
a = str[0].to_i
c = b = str[1].to_i
x = a.to_f
q = 1.0
count = 0
xc = 0
qc = 0
while b > 0 do
if b % 2 == 0
while x >= lim do
x /= lim
xc += m
end
x *= x
xc += xc
b >>= 1
else
q *= x
while q >= lim do
q /= lim
count += m
end
count += xc
b -= 1
end
end
num = q.to_i.to_s
if num.length == 1
num += "0"
end
print num[0], " ", num[1], " ", count + num.length - 1, "\n"
end
小指が強い人