题解 | #水仙花数#

水仙花数

https://www.nowcoder.com/practice/dc943274e8254a9eb074298fb2084703

import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int m = sc.nextInt();
            int n = sc.nextInt();
            boolean flag = false;
            for(int i = m; i <= n; i++){
                if(Math.pow(i/100,3)+Math.pow(i/10%10,3)+Math.pow(i%10,3) == i){
                    flag = true ;
                    System.out.print(i+" ");
                }
            }
            if(!flag){
                System.out.print("no");
            }
        }
    }
}

全部评论

相关推荐

给🐭🐭个面试机会...:我擦seed✌🏻
点赞 评论 收藏
分享
10-27 02:29
已编辑
门头沟学院 嵌入式工程师
牛客72783561...:简历不是这么写的,你这两个项目只说了用到了什么技术,却没说取得了什么成果,在我看来这就是你自己做的一个demo,没有价值。你为什么不写你电赛国二的那个项目?
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务