ACM Online Judgment For Ruby
Liber 2013-01-09 12:26

最近想找个支持Ruby的ACM在线系统玩玩,一方面喜欢ACM;另一方面,可以学习Ruby。

折腾了许久,终于有了结果,感谢主!

不敢独享,分享如下:

例子一:

Problem here:
https://www.spoj.com/problems/AMR10F/

My solution here:

N = gets
while( (data=gets) !=nil )
	arr = data.split(' ')
	sum = 0
	(1..(arr[0].to_i)).each do |nn|
		sum += (arr[1].to_i + arr[2].to_i * (nn-1))
	end
	puts sum
end

例子二:

Problem here:
https://www.spoj.com/problems/ADDREV/

My solution here:

N = gets
while( (data=gets) !=nil )
	arr = data.split(' ')
	result = arr[0].reverse.to_i + arr[1].reverse.to_i
	puts result.to_s.reverse.to_i
end