// Online IDE - Code Editor, Compiler, Interpreter
#include<iostream>
using namespace std;
int pow_recursive(int p, int q){
if(q==0) return 1;
if(q%2==0){
int result=pow_recursive(p,q/2);
return result*result;
}
else{
int result=pow_recursive(p,(q-1)/2);
return p*result*result;
}
}
int Armstong(int n, int count_zeroes){
if(n==0) return 0;
return pow_recursive(n%10,count_zeroes)+Armstong(n/10,count_zeroes);
}
int main()
{ int n;
cout<<"enter the value of n"<<endl;
cin>>n;
int count_zeroes=0;
int d=n;
while(d>0){
d=d/10;
count_zeroes++;
}
int result=Armstong(n,count_zeroes);
if(result==n){
cout<<"YES";
}
else{
cout<<"NO";
}
return 0;
}
Ci8vIE9ubGluZSBJREUgLSBDb2RlIEVkaXRvciwgQ29tcGlsZXIsIEludGVycHJldGVyCgojaW5jbHVkZTxpb3N0cmVhbT4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCBwb3dfcmVjdXJzaXZlKGludCBwLCBpbnQgcSl7CiAgICAgaWYocT09MCkgcmV0dXJuIDE7CiAgICAgaWYocSUyPT0wKXsKICAgICAgICAgaW50IHJlc3VsdD1wb3dfcmVjdXJzaXZlKHAscS8yKTsKICAgICAgICAgcmV0dXJuIHJlc3VsdCpyZXN1bHQ7CiAgICAgfQogICAgIGVsc2V7CiAgICAgICAgIGludCByZXN1bHQ9cG93X3JlY3Vyc2l2ZShwLChxLTEpLzIpOwogICAgICAgICByZXR1cm4gcCpyZXN1bHQqcmVzdWx0OwogICAgIH0KfQogICAgaW50IEFybXN0b25nKGludCBuLCBpbnQgY291bnRfemVyb2VzKXsKICAgICAgICBpZihuPT0wKSByZXR1cm4gMDsKICAgICAgICByZXR1cm4gcG93X3JlY3Vyc2l2ZShuJTEwLGNvdW50X3plcm9lcykrQXJtc3Rvbmcobi8xMCxjb3VudF96ZXJvZXMpOwogICAgfQppbnQgbWFpbigpCnsgICBpbnQgbjsKICAgIGNvdXQ8PCJlbnRlciB0aGUgdmFsdWUgb2YgbiI8PGVuZGw7CiAgICBjaW4+Pm47CiAgICBpbnQgY291bnRfemVyb2VzPTA7CiAgICBpbnQgZD1uOwogICAgd2hpbGUoZD4wKXsKICAgICAgZD1kLzEwOwogICAgICBjb3VudF96ZXJvZXMrKzsKICAgIH0KICAgIGludCByZXN1bHQ9QXJtc3Rvbmcobixjb3VudF96ZXJvZXMpOwogICAgaWYocmVzdWx0PT1uKXsKICAgICAgICBjb3V0PDwiWUVTIjsKICAgICAgICAKICAgIH0KICAgIGVsc2V7CiAgICAgICAgY291dDw8Ik5PIjsKICAgIH0KICAgIHJldHVybiAwOwp9CiAgICA=