Last active
July 31, 2017 02:34
-
-
Save whatalnk/b23bb1e209eee1a644e0743785acf423 to your computer and use it in GitHub Desktop.
AtCoder ABC #068 / ARC #079
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
puts "ABC" + gets.chomp |
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
n = gets.chomp.to_i | |
ans = 1 | |
ndiv = 0 | |
(1..n).each do |i| | |
x = i | |
if x.even? | |
tmp = 1 | |
while x.even? | |
x /= 2 | |
tmp += 1 | |
end | |
if tmp > ndiv | |
ndiv = tmp | |
ans = i | |
end | |
end | |
end | |
puts ans |
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
n, m = gets.chomp.split(" ").map(&:to_i) | |
cand = [] | |
ship = Array.new(n+1, false) | |
m.times do | |
a, b = gets.chomp.split(" ").map(&:to_i) | |
if b == n then | |
cand << a | |
elsif a == 1 then | |
ship[b] = true | |
end | |
end | |
cand.each do |i| | |
if ship[i] | |
puts "POSSIBLE" | |
exit | |
end | |
end | |
puts "IMPOSSIBLE" |
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
k = gets.chomp.to_i | |
n = 50 | |
ret = (0...n).to_a | |
x = k / n | |
rem = k % n | |
ret.map!{|i| i + x} | |
rem.times do |i| | |
amin = ret.min | |
imin = ret.index(amin) | |
ret.map!{|e| e - 1} | |
ret[imin] += (n + 1) | |
end | |
puts n | |
puts ret.join(" ") |
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
n = gets.chomp.to_i | |
arr = gets.chomp.split(" ").map(&:to_i) | |
ret = 0 | |
while arr.max >= n | |
s = arr.map{|x| x / n}.inject(:+) | |
arr.map!{|x| x + s - (n+1)*(x / n)} | |
ret += s | |
end | |
puts ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment