Blue Bridge Cup: Age issue (recommendation: maybe guess faster)

topic

   Title: Age Issue
   [Problem Description]
   Mrs. S has always been very mysterious. Someone asked her age at this moment. She thought about it and said:
"20 years ago, my husband's age was exactly twice mine, and now his age is just 1.5 times mine."

   Can you calculate the age of Mrs. S now?

   Note that what needs to be submitted is an integer, do not fill in any extra content.

Code

public class Main {
    
    
	public static void main(String []args){
    
    
		for(int i=20;i<100;i++){
    
    //s夫人的年龄,假设她不超过100岁(随便取的)
			for(int j=20;j<200;j++){
    
    //她丈夫的年龄,假设不超过200
				if((j-20)==(i-20)*2){
    
    
					if(j==i*1.5){
    
    
						System.out.println(i);
						break;
					}
				}
			}
		}
	}
}

answer

  40

Ideas

  Fill in the blanks, it may be faster to guess...

Guess you like

Origin blog.csdn.net/qq_47168235/article/details/109035435