Create a gist now

Instantly share code, notes, and snippets.

Educational Codeforces Round 1
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
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("")
@whatalnk
Owner
  • A
  • B
  • C
  • D
  • E
  • F
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment