问题陈述:一个人的年龄的三次方是四位数,四次方是六位数,一共这十位数恰好是0~9这没有重复的十个数字。求这个人的年龄是多少
用HashMap的求解给出自己的解决方法:
import java.util.HashMap;
/**
* Created by zmjs on 2015/10/21.
* 一个人的年龄的3次方是四位数,4次方是六位数,总共十位数刚好是0-9,求这个人的年龄。
*
*/
public class Age {
public static void main( String[] args ){
int age = (int)Math.pow(100000.0, 1.0/4);
boolean flag = false;
while(true){
int three = (int) Math.pow(age, 3);
int four = (int) Math.pow(age, 4);
if( three >= 1000 && three <= 9999 && four >= 100000 && four <= 999999 ){
String sThree = String.valueOf(three);
String sFour = String.valueOf(four);
/**
* Created by zmjs on 2015/10/21.
* 一个人的年龄的3次方是四位数,4次方是六位数,总共十位数刚好是0-9,求这个人的年龄。
*
*/
public class Age {
public static void main( String[] args ){
int age = (int)Math.pow(100000.0, 1.0/4);
boolean flag = false;
while(true){
int three = (int) Math.pow(age, 3);
int four = (int) Math.pow(age, 4);
if( three >= 1000 && three <= 9999 && four >= 100000 && four <= 999999 ){
String sThree = String.valueOf(three);
String sFour = String.valueOf(four);