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?

More than 1 year has passed since last update.

AtCoder初心者 DailyTrainingメモ 2023/11/12

Last updated at Posted at 2023-11-12

ABC277 A-問題

277A.png

ポイント
リストから要素を検索し、その位置を知るには indexを使う

277A.py
# 入力
N,X = map(int,input().split())
P = [0] + list(map(int, input().split()))

# リスト P の中で、X を検索する
ans = P.index(X)

print(ans)

ABC220 B-問題

問題文
整数 A,B が K 進法表記で与えられます。A×B を 10 進法表記で出力してください。

ポイント
先人の残した N進数の値を10進数に変換する関数を利用する

220B.py
# (N進数の数値,N進法)を10進数に変換する
def base_10(num_n,n):
    num_10 = 0
    for s in str(num_n):
        num_10 *= n
        num_10 += int(s)
    return num_10

# 入力
K = int(input())
A,B = map(int,input().split())

X = base_10(A,K)
Y = base_10(B,K)

print(X * Y)
0
0
0

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?