Last active
January 15, 2016 13:58
-
-
Save whatalnk/88ca347fcbb0eda7c5e2 to your computer and use it in GitHub Desktop.
Codeforces #339 Div2
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
l, r, k = gets.chomp.split(" ").map(&:to_i) | |
from = Math.log(l, k) | |
to = Math.log(r, k) | |
a = ((from.floor)..(to.ceil)).to_a.map{|i| k**i}.keep_if{|i| i >= l and i <= r} | |
if a.length == 0 then | |
puts -1 | |
else | |
puts a.join(" ") | |
end |
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.split(" ").map(&:to_i) | |
tanks = gets.chomp.split(" ") | |
pow = 0 | |
notbeautiful = "1" | |
tanks.each do |t| | |
n1 = t.count("1") | |
n0 = t.count("0") | |
nrem = t.length - n1 - n0 | |
if t.length == 1 && n0 == 1 then | |
puts 0 | |
exit | |
elsif n1 != 1 or nrem != 0 then | |
notbeautiful = t | |
else | |
pow += t.length - 1 | |
end | |
end | |
puts notbeautiful + "0" * pow |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment