AOJ

AOL(問題集)4

AIZU ONLINE JUDGE: Programming Challenge 0031 Weight def measure(object, weight, result = []) return result.join(" ") if weight.zero? result.unshift(weight) if (object / weight).nonzero? measure(object % weight, weight / 2, result) end $<.…

AOL(問題集)3

AIZU ONLINE JUDGE: Programming Challenge 0021 Parallelism $<.readlines.drop(1).map {|a| a.split.map(&:to_r)}.each do |x1, y1, x2, y2, x3, y3, x4, y4| puts((x2 - x1) * (y4 - y3) == (x4 - x3) * (y2 - y1) ? "YES" : "NO") end 単純な問題なのに…

AOL(問題集)2

AIZU ONLINE JUDGE: Programming Challenge 0011 Drawing Lots given = $<.readlines lines = [*0..given.first.to_i] given.drop(2).map {|x| x.split(",").map(&:to_i)}.each do |a, b| lines[a], lines[b] = lines[b], lines[a] end puts lines.drop(1) 0…

AOL(問題集)1

AIZU ONLINE JUDGE: Programming Challenge 0000 QQ 9.times do |i| 9.times {|j| puts "#{x = i + 1}x#{y = j + 1}=#{x * y}"} end 0001 List of Top 3 Hills puts $<.readlines.map(&:to_i).sort {|a, b| b <=> a}.take(3) 0002 Digit Number $<.readlines…

AOJ (Introduction to Algorithms and Data Structures)

AIZU ONLINE JUDGE: Programming Challenge ALDS1_1_A #挿入ソート gets ar = gets.split.map(&:to_i) n = ar.size putout = ->{puts ar.join(" ")} putout.() 1.upto(n - 1) do |i| v = ar[i] j = i - 1 while j >= 0 and ar[j] > v ar[j + 1] = ar[j] j -=…

AOJ (Introduction to Programming)

AIZU ONLINE JUDGE: Programming ChallengeITP1_1_A puts "Hello World" ITP1_1_B x = gets.to_i puts x ** 3 ITP1_1_C a, b = gets.split.map(&:to_i) puts "#{a * b} #{2 * (a + b)}" ITP1_1_D n = gets.to_i puts "#{n / 3600}:#{(n % 3600) / 60}:#{n % …