轩辕

运筹帷幄世界在我手中!

导航

杭电 2010 水仙花

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
 int count=0,i,m,n,d;
 while(cin>>m>>n)
 {
  count=0;
  for(i=m;i<=n;++i)
  {
   d=i;
   int sum=0;
           int j,yu;
 
     for(j=0;j<3;j++)
     {
      yu=d%10;
      sum=sum+pow(yu,3);
      d=d/10;
     }
     if(i==sum)
     {
      if(count>0)
       cout<<" "<<i;
      else
       cout<<i;
      count++;
     }
     if(i==n&&count>0)
     {
      cout<<endl;
  }}
    if(count==0)
     {
      cout<<"no"<<endl;
     }
  }
  return 0;
 
}

posted on 2011-08-19 16:24  峻华  阅读(140)  评论(0)    收藏  举报