Last active
August 6, 2017 02:43
-
-
Save whatalnk/286beab12009d13fb3ed5d574489754b to your computer and use it in GitHub Desktop.
ICPC Domestic 2012 Millennium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ICPC Domestic 2012 | |
# Millennium | |
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1179&lang=jp | |
n = gets.chomp.to_i | |
yday = Array.new(1000, 195) | |
yday[0] = 0 | |
(1..999).select{|i| i % 3 == 0}.each do |i| | |
yday[i] += 5 | |
end | |
(2..999).each do |i| | |
yday[i] += yday[i-1] | |
end | |
n.times do | |
y, m, d = gets.chomp.split(" ").map(&:to_i) | |
bday = yday[y-1] | |
if y % 3 == 0 then | |
bday += 20 * (m - 1) | |
bday += d | |
else | |
(1...m).each do |i| | |
if i.odd? | |
bday += 20 | |
else | |
bday += 19 | |
end | |
end | |
bday += d | |
end | |
puts yday[999] - bday + 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment