We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
using namespace std;
int sumofd(long long int a)
{
long long int s=0;
while(a!=0)
{
s=s+a%10;
a=a/10;
}
return s;
}
int sumofsq(long long int a)
{
if(a==0)
return 0;
else
return ((a%10)*(a%10)+sumofsq(a/10));
}
int main()
{
int t;
cin>>t;
while(t--)
{
long long int a,b,ans,ans2,c=0;
cin>>a;
cin>>b;
for(long long int i=a ; i<=b ; i++)
{
ans=sumofd(a);
ans2=sumofsq(a);
for(long long int j=2 ; j<=ans/2 ; ++j)
{
if(ans%j==0)
c++;
}
}
cout<
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Lucky Numbers
You are viewing a single comment's thread. Return to all comments →
Can someone tell me the error?
include
using namespace std; int sumofd(long long int a) { long long int s=0; while(a!=0) { s=s+a%10; a=a/10; }
return s; } int sumofsq(long long int a) { if(a==0) return 0; else return ((a%10)*(a%10)+sumofsq(a/10));
} int main() { int t; cin>>t; while(t--) { long long int a,b,ans,ans2,c=0; cin>>a; cin>>b; for(long long int i=a ; i<=b ; i++) { ans=sumofd(a); ans2=sumofsq(a); for(long long int j=2 ; j<=ans/2 ; ++j) { if(ans%j==0) c++; } } cout<