杭电2010-水仙花

#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int a,b,count,k1,k2,k3;
    while(cin>>a>>b)
    {
      for(count=0;a<=b;a++)
      {
         k1=a/100;
         k2=(a-k1*100)/10;
         k3=a-k1*100-k2*10;
         if(a==k1*k1*k1+k2*k2*k2+k3*k3*k3)
         {
             if(count!=0)
               cout<<" ";
             cout<<a;
             count++;
         }
         
      }
      if(count==0)
       cout<<"no"<<endl;
      else
      cout<<endl;
    }
    system("PAUSE");
    return EXIT_SUCCESS;
}

原文地址:https://www.cnblogs.com/wft1990/p/4322380.html