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 3 years have passed since last update.

ABC196 C - Doubled を解いた

Posted at

Abc196_1.png

文書のまま入力してみようと思った。
念のためサンプルを確認

Abc196_2.png

ふむふむ。とりあえず書いてみよう。

Doubled.py
N = int(input())       #N は偶数桁。
a,b = 1,1              # a と b を用意。
X = int(str(a)+str(b)) # a b を合体して X
lis = []               # 条件に合うものをを append
while X <= N:          
    lis.append(X)
    a += 1
    b += 1
    X = int(str(a)+str(b))
#print(lis)
print(len(lis))        #append した個数が答え

N は条件から 10^12 だが、a , b と分割して考える事で
a, b のそれぞれの最大値は 10**6 となるので間に合う算段だ。

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?