Help us understand the problem. What is going on with this article?

会津オンラインジャッジ解答

More than 1 year has passed since last update.
while input = gets
  n = input.chomp.to_i;
  if n>=1 && n<=999999
    for i in 2..n-1 do
      if n % i != 0
        if i == n-1
          puts n;
        end
        next;
      else
        break;
      end
    end
  else
    break;
  end
end

input_lines = readlines;
num = input_lines.length;
data_set = Array.new(num);

for i in 0..num-1
  data_set = input_lines[i].chomp.split(" ");
  a = data_set[0].to_f.round(4);
  b = data_set[1].to_f.round(4);
  c = data_set[2].to_f.round(4);
  d = data_set[3].to_f.round(4);
  e = data_set[4].to_f.round(4);
  f = data_set[5].to_f.round(4);

  y = (c-a*f/d)/(b-a*e/d);
  x = (c-b*y)/a;
  print x.floor;
  print " ";
  print y.floor;
  print "\n"
end

# Card Game
# 1回目
input = gets
n = input.chomp.to_i
sumA = 0;
sumB = 0;
while s = gets
  a,b = s.split(" ").map(&:to_i)
  a != b ? a > b ? sumA += (a+b) : sumB += (a+b) : (sumA += a && sumB += b)
end
puts sumA.to_s + ' ' + sumB.to_s

# 2回目
input = gets
n = input.chomp.to_i
sumA = 0;
sumB = 0;
n.times do
  a,b = gets.split(" ").map(&:to_i)
  a >= b ? a > b ? sumA += (a+b) : (sumA += a && sumB += b) : sumB += (a+b)
end
puts sumA.to_s + ' ' + sumB.to_s

# 3回目
loop{
  input = gets
  n = input.chomp.to_i
  break if n == 0
  sumA = sumB = 0;
  n.times do
    a,b = gets.split(" ").map(&:to_i)
    a >= b ? a > b ? sumA += (a+b) : (sumA += a && sumB += b) : sumB += (a+b)
  end
  puts "#{sumA} #{sumB}"
}

# 4回目
loop{
  input = gets
  n = input.chomp.to_i
  break if n == 0
  sumA = sumB = 0;
  n.times do |i|
    a,b = gets.split(" ").map(&:to_i)
    a >= b ? a > b ? sumA += (a+b) : (sumA += a && sumB += b) : sumB += (a+b)
  end
  puts [sumA, sumB].join(" ")
}


# Data Conversion
# 1回目
output = []
loop{
  n = gets.chomp.to_i
  break if n == 0
  a = b = Array.new(n)
  n.times do |i|
    a[i],b[i] = gets.chomp.split(" ")
  end

  m = gets.chomp.to_i
  m.times do |j|
    c = gets.chomp
    index = a.index(c) && output.push(b[:index]) if a.include?(c)
  end
}
puts output.join


# 2回目
loop{
  n = gets.chomp.to_i
  break if n == 0
  hash = {}
  n.times do
    c0,c1 = gets.chomp.split(" ")
    hash[c0] = c1
  end

  m = gets.chomp.to_i

  input = ''
  output = ''

  m.times do
    c0 = gets.chomp
    c1 = hash[c0]
    input += c0
    output += c1.nil? ? c0 : c1
  end
  puts output
}
Cup
# 1回目
loop{
  n, m = gets.chpmp.split(" ").map(&:to_i)
  a
  n.times do |i|
    gets != "0" ? A = gets.chomp.split(" ").map(&:to_i) : A = 0
    gets != "0" ? B = gets.chomp.split(" ").map(&:to_i) : B = 0
    gets != "0" ? C = gets.chomp.split(" ").map(&:to_i) : C = 0
    A.shift
    B.shift
    C.shift


  end
 }
Dice.rb
loop{
  n = gets.chomp.to_i
  break if n == 0
  # hash = { "上": 1, "手前": 2, "右": 3, "左": 4, "奥": 5, "下": 6 }
  ary = [1, 2, 3, 4, 5, 6]
  sum = 1
  n.times do
    houkou = gets.chomp
    if houkou == "North"
      ary[0], ary[5] = ary[5], ary[0]
      ary[0], ary[1] = ary[1], ary[0]
      ary[4], ary[5] = ary[5], ary[4]
      sum += ary[0]
    elsif houkou == "East"
      ary[0], ary[2] = ary[2], ary[0]
      ary[3], ary[5] = ary[5], ary[3]
      ary[0], ary[5] = ary[5], ary[0]
      sum += ary[0]
    elsif houkou == "West"
      ary[0], ary[2] = ary[2], ary[0]
      ary[3], ary[5] = ary[5], ary[3]
      ary[2], ary[3] = ary[3], ary[2]
      sum += ary[0]
    elsif houkou == "South"
      ary[0], ary[1] = ary[1], ary[0]
      ary[4], ary[5] = ary[5], ary[4]
      ary[0], ary[5] = ary[5], ary[0]
      sum += ary[0]
    elsif houkou == "Right"
      ary[1], ary[2] = ary[2], ary[1]
      ary[3], ary[4] = ary[4], ary[3]
      ary[2], ary[3] = ary[3], ary[2]
      sum += ary[0]
    else
      ary[1], ary[2] = ary[2], ary[1]
      ary[3], ary[4] = ary[4], ary[3]
      ary[1], ary[4] = ary[4], ary[1]
      sum += ary[0]
    end
  end
  puts sum
}

Syutai
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした