समस्या
अनुवाद दिखाएँ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 के लिए अनुकूलित की गई है। ऊपर दिए गए स्टेटमेंट और सीमाओं का पालन करें।