蓝桥杯立方尾不变

package com.lqb.one;

//立方尾不变
//
//有些数字的立方的末尾正好是该数字本身。
//比如:1,4,5,6,9,24,25,....
//
//请你计算一下,在10000以内的数字中(指该数字,并非它立方后的数值),符合这个特征的正整数一共有多少个。
//
//请提交该整数,不要填写任何多余的内容。


public class LFWBB {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int count = 0;
		int k = 0;
		String str = "";
		for(int i=1;i<=10000;i++) {
			k = i*i*i;
			String str1 = ""+i;
			str = Integer.toString(k);
			if(str.endsWith(str1)) {
				count +=1;
				System.out.print(i+" "+"\n");
			}
		}
		System.out.println(count);
	}

}

posted @ 2019-12-27 20:22  饭小乖  阅读(216)  评论(0编辑  收藏  举报