Qiita Teams that are logged in
You are not logged in to any team

Community
Service
Qiita JobsQiita ZineQiita Blog
1
Help us understand the problem. What is going on with this article?
@yopya

# Project Euler 56「もっとべき乗の数字和」

More than 3 years have passed since last update.

かい…かん

# Problem 56 「もっとべき乗の数字和」

Googol (10^100)は非常に大きな数である: 1の後に0が100個続く. 100^100は想像を絶する. 1の後に0が200回続く. その大きさにも関わらず, 両者とも数字和 ( 桁の和 ) は1である.
a, b < 100 について自然数 a^b を考える. 数字和の最大値を答えよ.

``````def hoge(num):
return max(sum((lambda l: (int(x) for x in l))(str(a**b)))
for a in range(1, num)
for b in range(1, num))

print(hoge(100))
``````

## カンニング後追記

こういう時にmap関数を使うんですね。

``````map(int, str(a**b))
``````
``````(lambda l: (int(x) for x in l))(str(a**b))
``````

1
Help us understand the problem. What is going on with this article?
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