首页 > 编程语言 > 详细

HackerRank - Filling Jars

时间:2015-02-27 16:25:54      阅读:312      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!