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 Some Sums (AtCoder Beginner Contest 083) へのコメント

Last updated at Posted at 2021-11-20

問題
https://atcoder.jp/contests/abc083/tasks/abc083_b

13,14,,,などの数字は1+3、1+4,,,と足す必要がある。
数字のままでは13を1と3に分解することができないので、13を一度文字列に変えて1と3に変更する→数字に戻して1と3を足し合わせる必要がある。

N, A, B = map(int, input().split())

answer = 0

for i in range(N+1):
  s = str(i) # 数字の20を文字の20に変える 
  n_list = list(map(int, s)) # 右のlist(~で配列を宣言し、map関数で文字列sをintに変換
  summary = sum(n_list)
  
  if A <= summary <= B # summaryがA以上B以下の時、足す
       answer += i

print(answer)

0
0
2

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?