はじめに
この記事では、AtCoder Beginer Contest 172のA~D問題を解説します。
A - Calc
https://atcoder.jp/contests/abc172/tasks/abc172_aPython
の累乗は第一引数と第二引数が共に整数であれば、整数を返すので問題ありません。
1 | a = int(input()) |
B - Minor Change
https://atcoder.jp/contests/abc172/tasks/abc172_b
一文字ずつ判定をしていけば良いです。
1 | S = input() |
C - Tsundoku
https://atcoder.jp/contests/abc172/tasks/abc172_c
累積和を用いることでO(M+N)
で求めることができます。
1 | import itertools |
D - Sum of Divisors
https://atcoder.jp/contests/abc172/tasks/abc172_d
公式解説の解法の通りに実装すれば、O(N)
です。
1 | N = int(input()) |
二重ループ内の計算が軽いため、PyPy
であれば以下のコードでもAC
できます。
1 | N = int(input()) |
関連記事
過去のABC解説記事です。
- ABC171
- A-E問題を解いています。
- ABC170
- A-D問題を解いています。
- ABC169
- A-F問題を解いています。
- ABC168
- A-E問題を解いています。
- ABC167
- A-E問題を解いています。
- ABC166
- A-F問題を解いています。
- ABC165
- A-F問題を解いています。
- ABC164
- A-E問題を解いています。
- ABC163
- A-D問題を解いています。
- ABC162
- A-E問題を解いています。
記事情報
- 投稿日:2020年6月27日
- 最終更新日:2020年6月27日