Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Last active November 5, 2015 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whatalnk/246c5c9c1a70c78b3324 to your computer and use it in GitHub Desktop.
Save whatalnk/246c5c9c1a70c78b3324 to your computer and use it in GitHub Desktop.
Codeforces #328 Div2
# [Problem - 592A - Codeforces](http://codeforces.com/problemset/problem/592/A)
field = []
while line = gets
field << line.chomp.split("")
end
field = field.transpose
stepA = []
stepB = []
field.each do |r|
a = r.rindex("W")
b = r.rindex("B")
unless b.nil? then
if a.nil? or (a < b) then
stepB << 7 - b
end
end
a = r.index("W")
b = r.index("B")
unless a.nil? then
if b.nil? or (a < b) then
stepA << a
end
end
end
if stepB.empty? or (stepA.min <= stepB.min) then
puts "A"
elsif stepA.empty? or (stepA.min > stepB.min) then
puts "B"
end
# [Problem - 592B - Codeforces](http://codeforces.com/problemset/problem/592/B)
n = gets.chomp.to_i
if n == 3 then
puts 1
else
a1 = 1
4.upto(n).each do |a|
a1 += 3 + 2*(a-4)
end
puts a1
end
# [Problem - 592C - Codeforces](http://codeforces.com/problemset/problem/592/C)
t, w, b = gets.chomp.split(" ").map(&:to_i)
res = 0
(1..t).each do |i|
ww = i / w
www = w * ww
bb = i / b
bbb = b * bb
if www ==bbb then
res += 1
end
end
puts Rational(res, t)
@whatalnk
Copy link
Author

whatalnk commented Nov 5, 2015

  • A
  • B
  • C
  • D
  • E

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment