Drkcore

17 09 2008 euler Tweet

Project Euler Problem 63&99

problem 63

n乗したらn桁がなるような数字はいくつあるか?

10以上は考えなくてよいのだけど、一応100まで数えてみた。

count = 0
for i in range(1,100):
    if len(str(i)) > 1: break

    j = 1
    while(1):
        n = i ** j
        if len(str(n)) < j: break
        # print n,i,j
        j += 1
        count += 1

print count

problem 99

対数変換して比較するだけなのでlog10で。

import math
f = open("base_exp.txt")

n    = 0
max  = 0
maxn = 0
for l in f:
    n += 1
    a,b = l[:-2].split(',')
    x = math.log(int(a)) * int(b)
    if max < x:
        max = x
        maxn = n
print maxn,max

これで、level2の六面体に昇進

About

  • もう5年目(wishlistありマス♡)
  • 最近はPythonとDeepLearning
  • 日本酒自粛中
  • ドラムンベースからミニマルまで
  • ポケモンGOゆるめ

Tag

Python Deep Learning javascript chemoinformatics Emacs sake and more...

Ad

© kzfm 2003-2021