0
点赞
收藏
分享

微信扫一扫

1252: [蓝桥杯2015初赛]奇妙的数字

就是耍帅 2022-02-07 阅读 58

import java.util.HashSet;

public class t1252 {
    public static void main(String[] args) {
        int s=1;
        int num=0;
        while (s!=0){
            int pow2 = num*num;
            int pow3 = num*num*num;
            HashSet<Object> set = new HashSet<>();
            while (pow2!=0){
                int n = pow2%10;
                pow2= pow2/10;
                set.add(n);
            }
            while (pow3!=0){
                int n = pow3%10;
                pow3= pow3/10;
                set.add(n);
            }
            if (set.size()==10){
                s=0;
            }else {num++;}
        }
        System.out.println(num);
    }
}
举报

相关推荐

0 条评论