Skip to content

Instantly share code, notes, and snippets.

@pinglunliao
Last active November 5, 2019 08:36
Show Gist options
  • Save pinglunliao/5a0bf2773f36d1b0608b to your computer and use it in GitHub Desktop.
Save pinglunliao/5a0bf2773f36d1b0608b to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int main()
{
int armstrongNum[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
153, 370, 371, 407,
1634, 8208, 9474,
54748, 92727, 93084,
548834
};
short SIZE = sizeof(armstrongNum) / sizeof(int);
bool isArmstrong[1000000];
for(int i = 0; i < SIZE; i++)
isArmstrong[armstrongNum[i]] = true;
int a, b;
while(cin >> a >> b)
{
bool hasArm = false;
for( ; a <= b; a++ )
{
if(isArmstrong[a])
{
cout << a << " ";
hasArm = true;
}
}
if(!hasArm)
cout << "none";
cout << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment