Created
November 19, 2015 10:39
-
-
Save whatalnk/9bde39cdf197246a9631 to your computer and use it in GitHub Desktop.
Educational Codeforces Round 1
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
t = gets.chomp.to_i | |
t.times do | |
n = gets.chomp.to_i | |
power2 = [] | |
snd = 1 | |
i = 1 | |
while snd <= n | |
power2 << snd | |
snd = 2**i | |
i += 1 | |
end | |
puts n*(n+1)/2 - 2 * power2.inject(:+) | |
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
s = gets.chomp.split("") | |
m = gets.chomp.to_i | |
m.times do | |
l, r, k = gets.chomp.split(" ").map(&:to_i) | |
kk = k % (r - l + 1) | |
sr = [] | |
kk.times do | |
sr.unshift(s.slice!(r-1)) | |
r -= 1 | |
end | |
s.insert(l-1, sr).flatten! | |
end | |
puts s.join("") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dashboard - Educational Codeforces Round 1 - Codeforces