码迷,mamicode.com
首页 > 编程语言 > 详细

HackerRank - Filling Jars

时间:2015-02-27 16:26:59      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:

The punch line to this problem is the support to very very large int handling. I tried C++ code for multiple times, but it only passed first 13~ cases.

Then I tried Ruby and got it passed all:

meta = gets.chomp
nm = meta.split( )
n = nm.first.to_i
m = nm.last.to_i

total = 0
for i in 0..m-1
   triple = gets.chomp
   vs = triple.split( )
   vs = vs.map(&:to_i)
   total += vs[2] * (vs[1] - vs[0] + 1)   
end

puts total / n

However, there are a bunch of all-passing C++ solutions. I also used ‘long long‘ actually... weird

HackerRank - Filling Jars

标签:

原文地址:http://www.cnblogs.com/tonix/p/4303333.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!