結果

問題 No.219 巨大数の概算
ユーザー NabetaniNabetani
提出日時 2015-10-25 00:18:28
言語 Ruby
(3.3.0)
結果
AC  
実行時間 335 ms / 1,500 ms
コード長 511 bytes
コンパイル時間 186 ms
コンパイル使用メモリ 11,388 KB
実行使用メモリ 15,880 KB
最終ジャッジ日時 2023-09-25 14:56:08
合計ジャッジ時間 19,563 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 325 ms
15,848 KB
testcase_01 AC 332 ms
15,596 KB
testcase_02 AC 326 ms
15,552 KB
testcase_03 AC 328 ms
15,720 KB
testcase_04 AC 329 ms
15,696 KB
testcase_05 AC 79 ms
15,564 KB
testcase_06 AC 106 ms
15,656 KB
testcase_07 AC 81 ms
15,640 KB
testcase_08 AC 106 ms
15,796 KB
testcase_09 AC 80 ms
15,376 KB
testcase_10 AC 332 ms
15,556 KB
testcase_11 AC 334 ms
15,716 KB
testcase_12 AC 327 ms
15,688 KB
testcase_13 AC 327 ms
15,792 KB
testcase_14 AC 329 ms
15,752 KB
testcase_15 AC 330 ms
15,756 KB
testcase_16 AC 333 ms
15,660 KB
testcase_17 AC 332 ms
15,740 KB
testcase_18 AC 331 ms
15,792 KB
testcase_19 AC 327 ms
15,652 KB
testcase_20 AC 329 ms
15,756 KB
testcase_21 AC 330 ms
15,528 KB
testcase_22 AC 331 ms
15,652 KB
testcase_23 AC 327 ms
15,620 KB
testcase_24 AC 333 ms
15,824 KB
testcase_25 AC 328 ms
15,788 KB
testcase_26 AC 331 ms
15,556 KB
testcase_27 AC 331 ms
15,696 KB
testcase_28 AC 331 ms
15,696 KB
testcase_29 AC 330 ms
15,720 KB
testcase_30 AC 329 ms
15,880 KB
testcase_31 AC 331 ms
15,580 KB
testcase_32 AC 327 ms
15,704 KB
testcase_33 AC 332 ms
15,784 KB
testcase_34 AC 330 ms
15,780 KB
testcase_35 AC 331 ms
15,688 KB
testcase_36 AC 327 ms
15,756 KB
testcase_37 AC 332 ms
15,600 KB
testcase_38 AC 335 ms
15,692 KB
testcase_39 AC 330 ms
15,684 KB
testcase_40 AC 333 ms
15,704 KB
testcase_41 AC 328 ms
15,740 KB
testcase_42 AC 325 ms
15,616 KB
testcase_43 AC 329 ms
15,600 KB
testcase_44 AC 331 ms
15,552 KB
testcase_45 AC 327 ms
15,764 KB
testcase_46 AC 328 ms
15,708 KB
testcase_47 AC 330 ms
15,596 KB
testcase_48 AC 328 ms
15,652 KB
testcase_49 AC 328 ms
15,776 KB
testcase_50 AC 329 ms
15,740 KB
testcase_51 AC 79 ms
15,532 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def calc(a, e, b)
  case b
  when 0
    return [1, 0, 1]
  when 1
    return [a, e, 1]
  end
  x=calc(a, e, b/2)
  y=b.even? ? [ 1, 0, 1 ] : [a, e, 1]
  xy=[x[0]*x[0]*y[0], x[1]*2+y[1], 1]
  po=Math.log10(xy[0]).floor
  [xy[0]/10.0**po, xy[1]+ po, 1]
end

def solve_impl( a, b )
  v=calc(a, 0, b)
  x, y = (v[0]*10).floor.to_s.chars
  [x, y, v[1]]
end

def solve2(input)
  n=input.gets.to_i
  n.times do
    q=input.gets.split(/\s+/).map(&:to_i)
    puts( solve_impl( *q ).join(" ") )
  end
end

solve2($stdin)
0