0
点赞
收藏
分享

微信扫一扫

step_1_入门_ACM趣味题_4 水仙花数

NicoalsNC 2022-02-10 阅读 48


acm.hdu.edu.cn/showproblem.php?pid=2010

#include<iostream>
#include<cmath>
using namespace std;
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(0);
int m,n;
while(cin>>m>>n){
bool flag=false;
for(int i=m;i<=n;i++){
int num=i;
int a=num/100;
num%=100;
int b=num/10;
int c=num%10;
if(a*a*a+b*b*b+c*c*c==i){
if(flag)cout<<" "<<i;
else{
flag=true;
cout<<i;
}
}
}if(!flag)cout<<"no";
cout<<endl;

}
return 0;
}



举报

相关推荐

水仙花数(java)

打印水仙花数

JAVA——水仙花数

c水仙花数

计算“水仙花数”

0 条评论