Skip to content

Instantly share code, notes, and snippets.

View hamuhei1412's full-sized avatar

hamuhei1412 hamuhei1412

View GitHub Profile
puts "moke" #文字列
puts ans # 変数も可
@hamuhei1412
hamuhei1412 / string.rb
Created March 21, 2018 13:31
文字列
str = gets
@hamuhei1412
hamuhei1412 / ar.rb
Created March 21, 2018 13:31
複数行に渡り配列
moke = []
N.times { moke << gets.to_i }
@hamuhei1412
hamuhei1412 / AR.rb
Created March 21, 2018 13:29
配列
hoge = gets.split.map(&:to_i)
@hamuhei1412
hamuhei1412 / NM.rb
Created March 21, 2018 13:26
空白区切りN
N,M = gets.split.map(&:to_i)
@hamuhei1412
hamuhei1412 / N.rb
Created March 21, 2018 13:25
一つのN
N = gets.to_i
@hamuhei1412
hamuhei1412 / ABC088B.rb
Last active March 21, 2018 14:57
ABC088B
N = gets.to_i
hoge = gets.split.map(&:to_i)
#ここまで入力
hoge.sort! #小さい順にソート
hoge.reverse! #それを逆順にひっくり返すことによって実質大きい順ソートに
s = 0 #これが偶数の時はAliceの番で、奇数の時はBobの番
Alice = 0
Bob = 0
while s < N
if(s%2==0)
@hamuhei1412
hamuhei1412 / ABC087B.rb
Last active March 21, 2018 14:49
ABC087B
A = gets.to_i
B = gets.to_i
C = gets.to_i
X = gets.to_i
#ここまで入力
ans = 0
a = 0 #500円玉の枚数
while a != A+1 do
b = 0 #100円玉の枚数
while b != B+1 do
@hamuhei1412
hamuhei1412 / ABC086C.rb
Last active March 21, 2018 15:07
ABC086C
N = gets.to_i
x = []
y = []
t = []
N.times do
line = gets.split.map(&:to_i)
t << line[0]
x << line[1]
y << line[2]
end
@hamuhei1412
hamuhei1412 / ABC085C.rb
Last active March 21, 2018 15:11
ABC085C
Y,N = gets.split.map(&:to_i) #入力
a = 0 #一万円の枚数
while a * 10000 <= N
b = 0 #5000円の枚数
while b * 5000 + a * 10000 <= N
c = (N - (a * 10000 + b * 5000)) / 1000 #1万円の枚数と5000円の枚数が決まれば、考えられる千円札の枚数は一意に決まる。
if(a+b+c==Y&&a*10000+b*5000+c*1000==N) #枚数がYかつ合計金額がNなら出力して終了
puts "#{a} #{b} #{c}"
exit
end