Java Blue Bridge Cup Test Problem B: Anniversary

Question B: Anniversary

Total score for this question: 5 points


【Problem Description】


July 1, 2020 is the 99th anniversary of the founding of the Communist Party of China.
The Communist Party of China was established on July 23, 1921.
How
many minutes are included from 12:00 noon on July 23, 1921 to 12:00 noon on July 1, 2020 ?
[Answer submission]
This is a result fill-in-the-blank question, you only need to calculate the result and submit it. The result of this question is an
integer. When submitting the answer, only fill in this integer. If you fill in the extra content, you will not be able to score.


package MingxuDeng;
/*
 *@author  MingxuDeng
 *@version 20202020年10月14日

【问题描述】

2020 年 7 月 1 日是中国共产党成立 99 周年纪念日。中国共产党成立于 1921 年 7 月 23 日。
请问从 1921 年 7 月 23 日中午 12 时到 2020 年 7 月 1 日中午 12 时一共包含多少分钟?
【答案提交】
这是一道结果填空题,你只需要算出结果后提交即可。本题的结果为一个整数,在提交答案时只填写这个整数,填写多余的内容将无法得分。
*/
public class Main {
    
    
	// 思路:统计出天数,每天24小时,每小时60分钟,最后便可以得到结果
	public static void main(String[] args) {
    
    
		int day=0,r=0;
		for(int i=1922;i<=2019;i++) {
    
    
			if(i%4==0||i%400==0) {
    
    //闰年  366 天
				day+=366;
			}else {
    
    //平年 365天
				day+=365;
			}
		}
		/*t1(1921.7.23 12:00 ~ 1921.12.31 24:00) + t2(2020.1.1 00:00 ~ 2020.7.1 12:00)
		 * 可以知道,这两段时间加在一起就是比  366天(因为2020年的2月是29天,所以不是365,而是366)少  22 天,
		 * 所以366-22=344
		 */
		day+=344;
		
		r=day*24*60;
		System.out.println(r);//52038720
		
	}

}

Guess you like

Origin blog.csdn.net/DAurora/article/details/109069781