0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

競技プログラミングでよく使うpythonでの入力

Posted at

競技プログラミングでよく使うpythonでの入力について書いていきます
(少し説明が雑です)

1.整数の入力

N = int(input())
#1つの整数の入力
A, B = map(int, input().split())
#複数の整数の入力
L = list(map(int, input().split()))
#配列の入力
D = [list(map(int, input().split())) for _ in range(N)]
#2次元配列の入力(この場合はN行)

小数の場合はintfloatに変えてください。

2.文字列の入力

S = input()
#1つの文字列の入力
A, B = input().split()
#複数の整数の入力整数の入力
L = list(input().split())
#文字列の配列の入力1
M = [input() for _ in range(N)]
#文字列の配列の入力2(この場合は行)
C = list(input())
#文字列を文字にして入力

3.よく出る特殊例

文字列,整数の順で1行入力

S, A = input().split()
A = int(A)
0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?