立方尾不变
2017-12-16 20:35
120 查看
有些数字的立方的末尾正好是该数字本身。
比如:1,4,5,6,9,24,25,....
请你计算一下,在10000以内的数字中(指该数字,并非它立方后的数值),符合这个特征的正整数一共有多少个。
分析:
数字的立方的末尾正好是该数字本身
数字的末尾 = 数字%(10的(数字的长度)的方)
25%10 = 5
123%10*10 = 3
代码如下:
public class a1
{
public a1(){
int count = 0;
for (int i =
0; i < 10000;
i++) {
String
s = String.valueOf(i);
if( Math.pow(i,
3)%(Math.pow(10,
s.length())) ==
i ){
System.out.println(i);
}
}
System.out.printf("一共有%d个",count);
}
public static void main(String[]
args) {
//
TODO Auto-generated method stub
new a1();
}
}
比如:1,4,5,6,9,24,25,....
请你计算一下,在10000以内的数字中(指该数字,并非它立方后的数值),符合这个特征的正整数一共有多少个。
分析:
数字的立方的末尾正好是该数字本身
数字的末尾 = 数字%(10的(数字的长度)的方)
25%10 = 5
123%10*10 = 3
代码如下:
public class a1
{
public a1(){
int count = 0;
for (int i =
0; i < 10000;
i++) {
String
s = String.valueOf(i);
if( Math.pow(i,
3)%(Math.pow(10,
s.length())) ==
i ){
System.out.println(i);
}
}
System.out.printf("一共有%d个",count);
}
public static void main(String[]
args) {
//
TODO Auto-generated method stub
new a1();
}
}
相关文章推荐
- 蓝桥杯第六届 立方尾不变
- 第六届蓝桥杯 软件类省赛真题 第二题:立方尾不变
- 第六届蓝桥杯立方尾不变
- 蓝桥杯历届-立方尾不变
- 2015年蓝桥杯C组第二题:立方尾不变
- 立方尾不变
- 立方尾不变
- 立方尾不变
- 蓝桥杯-立方尾不变-java
- 第六届蓝桥杯 java C组 立方尾不变
- 备战蓝桥杯(真题)第六届第二题“立方尾不变”
- 蓝桥杯—立方尾不变,有些数字的立方的末尾正好是该数字本身
- C# 概念 协变,逆变 ,不变体
- 网络-数据包在路由转发过程中MAC地址和IP地址,变与不变
- 变与不变---敏捷小思考(1)
- DataGridView左键选中行改变行背景色,右键选中行不改变背景色。左键选中行的背景色不变
- 训练Cifar10网络时,遇到训练结果始终Accuracy不变,Loss=87.33的情况
- android 在多个页面之间实现底部悬浮框不变
- UIButton 关掉交互后title不变的坑
- 已知某公司总人数为W,平均年龄为Y岁(每年3月末计算,同时每年3月初入职新人),假设每年离职率为x,x>0&&x<1,每年保持所有员工总数不变进行招聘,新员工平均年龄21岁。 从今年3月末开始,请实现一个算法,可以计算出第N年后公司员工的平均年龄。(最后结果向上取整)。