問題
翻訳を表示A number with k digits is an Armstrong number if the sum of each digit raised to the power k equals the number. For example 153 = 1³ + 5³ + 3³.
Implement is_armstrong(n).
Input
n: A non-negative integer.
Output
Return true if n is an Armstrong number.
制約
0 ≤ n ≤ 10¹⁸
例
例 1
入力:
n = 153
期待される出力:
expected = True
入力:
long long n = 153;
期待される出力:
bool expected = true;
入力:
long n = 153;
期待される出力:
bool expected = true;
解説
1³ + 5³ + 3³ = 1 + 125 + 27 = 153.
例 2
入力:
n = 10
期待される出力:
expected = False
入力:
long long n = 10;
期待される出力:
bool expected = false;
入力:
long n = 10;
期待される出力:
bool expected = false;
解説
1² + 0² = 1, which is not 10.
参考資料
この課題はCodeUtility用に調整されています。上記の説明と制約に従ってください。