Skip to content

Instantly share code, notes, and snippets.

@kjugk
Last active March 23, 2023 02:23
Show Gist options
  • Save kjugk/38d0ba955e42b52634a574932a5a9802 to your computer and use it in GitHub Desktop.
Save kjugk/38d0ba955e42b52634a574932a5a9802 to your computer and use it in GitHub Desktop.
AtCoder で標準入力を処理する (Ruby)

整数

n = gets.to_i

スペース区切りの整数

a, b, c = gets.split.map(&:to_i)

改行区切りの整数

n = gets.to_i
a = n.times.map { gets.to_i }

文字列

s = gets

スペース区切りの文字列

s, t = gets.split

改行区切りの文字列

n = gets.to_i
s = n.times.map { gets.chomp }

スペース区切りの浮動小数点数

x, y = gets.split.map(&:to_f)

行列

n, m = gets.split.map(&:to_i)
a = n.times.map { gets.split.map(&:to_i) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment