Help us understand the problem. What is going on with this article?

Atcoder Beginner Contest152のきろく(python)

1

正答数と問題数が一致した時ACとする

N , M = map(int,input().split())
if N == M:
    print("Yes")
else:
    print("No")

2

辞書順で先に来るとは数が小さいことと同義である。
その為、smallの値をlargeの回数繰り返せば良い

a, b = map(int,input().split())
ans = str(min(a, b)) * max(a, b)
print(ans)

3

chokudaiさんも解けてほしいと言っていた問題。
問題文が複雑であるが、問題文をあるiが任意のすべてのjのうち最小であるという問題に帰着できる。
その為、左から値を保持し、常に最小であるか判定すれば$O(N)$で解ける。

N = int(input())
P = list(map(int, input().split()))
now = P[0]
ans = 1
for i in range(1, N):
    if now >= P[i]:
        now = P[i]
        ans += 1
print(ans)

4

条件に適した二組の整数が何個あるかの問題。

制約より、$O(N)$で解けることがわかる。また、1〜20くらいまで書き出すと明確な法則がないように思える。

この問題のポイントは値を1〜9までしか使わない為、9*9の二次元配列を作る。それをforでカウントし、2数の組合せが答えとなる。

from pprint import pprint
N = int(input())
digit_cnt = list([0] * 9 for _ in range(9))
now = 1
for i in range(1, N + 1):
    str_i = str(i)
    row = int(str_i[0])
    column = int(str_i[-1])
    if row != 0 and column != 0:
        digit_cnt[row - 1][column - 1] += 1
# pprint(digit_cnt)

ans = 0
for i in range(9):
    for j in range(9):
        ans += digit_cnt[i][j] * digit_cnt[j][i]
print(ans)
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした