MOD = 2 ** 32 # MOD = 7 A, B, x0, N = gets.split.map(&:to_i) @temp = x0 def randin @temp = (A * @temp + B) % MOD return @temp % 6 + 1 # return @temp end tk = [0,0] tknow = 0 aok = [0,0] aoknow = 0 (N * 2).times do |i| pre = randin if i.even? tknow += pre if tknow.even? tk[0] += 1 else tk[1] += 1 end else aoknow += pre if aoknow.even? aok[0] += 1 else aok[1] += 1 end end end puts "#{tk.min} #{aok.min}"