Created
October 29, 2017 18:38
-
-
Save whatalnk/b9ea23b8b3fe84a596747f90fc373014 to your computer and use it in GitHub Desktop.
AtCoder ABC #076
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
r = gets.chomp.to_i | |
g = gets.chomp.to_i | |
puts 2 * g - r |
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 | |
k = gets.chomp.to_i | |
x = 1 | |
n.times do | |
a = x * 2 | |
b = x + k | |
x = [a, b].min | |
end | |
puts x |
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
s = gets.chomp | |
t_ = gets.chomp | |
ns = s.length | |
nt = t_.length | |
arr = [] | |
(ns - nt + 1).times do |i| | |
x = s.clone | |
ss = s[i..(i + nt - 1)] | |
ok = true | |
nt.times do |j| | |
if ss[j] != "?" && ss[j] != t_[j] | |
ok = false | |
end | |
end | |
if ok | |
x[i, nt] = t_ | |
arr << x | |
end | |
end | |
if arr.empty? | |
puts "UNRESTORABLE" | |
else | |
arr.sort! | |
ans = arr[0].gsub("?", "a") | |
puts ans | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment