Skip to content

Instantly share code, notes, and snippets.

@goish135
Created October 15, 2021 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goish135/b2e1a498d0fc5d1f1bdac1ddab273227 to your computer and use it in GitHub Desktop.
Save goish135/b2e1a498d0fc5d1f1bdac1ddab273227 to your computer and use it in GitHub Desktop.
#include<iostream>
using namespace std;
int main()
{
int n,m;
cin >> n >> m; // [100,400]
int i = n;
int total = 0;
while(i<=m)
{
//cout << "In" << endl;
int tmp;
tmp = i;
int sum=0;
while(tmp)
{
int d;
d=tmp%10;
//print("d",d);
//cout << d << endl;
sum+=(d*d*d);
tmp/=10;
}
//cout << sum << endl;
if(sum==i)
{
cout << sum << endl;
total+=1;
}
i++;
}
cout << "total:" << total << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment