您的位置:首页 > 其它

HDU 2010 水仙花数

2010-05-02 19:48 274 查看
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2010



相当简单的一道练习题,只是突然想起今年是2010年,做一下玩。

提交代码:

#include <iostream>
#include <vector>
using namespace std;

void main()
{
int m,n;
while(cin>>m>>n)
{
vector<int> v;
for (int i=m;i<=n;i++)
{
int a,b,c;
int temp=i;
c=temp%10;
temp/=10;
b=temp%10;
a=temp/10;
if(a*a*a+b*b*b+c*c*c==i)
v.push_back(i);
}
if(v.size()==0)
cout<<"no"<<endl;
else
{
for (int j=0;j<v.size()-1;j++)
{
cout<<v[j]<<" ";
}
cout<<v[j]<<endl;
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: