47 lines
972 B
Java
47 lines
972 B
Java
package LanQiaoOJ;
|
||
/*
|
||
* 小蓝每天都锻炼身体。
|
||
正常情况下,小蓝每天跑1干米。如果某天是周一或者月初(1日),为了激励自己,小蓝要跑2干米。如果同时是周一
|
||
或月初,小蓝也是跑2干米。小蓝跑步已经坚持了很长时间,从2000年1月1日周六(含)到2020年10月1日周四(含)。
|
||
请问这段时间小蓝总共跑步多少干米?*/
|
||
public class 跑步锻炼 {
|
||
//每月天数
|
||
static int []w= {0,31,28,31,30,31,30,31,31,30,31,30,31};
|
||
//定义年月日
|
||
//t=1表示星期一,t=0表示星期天
|
||
static int y=2000,m=1,d=1,t=6;
|
||
static int count=0;
|
||
public static void main(String[] args) {
|
||
// TODO Auto-generated method stub
|
||
|
||
while(y!=2020||m!=10||d!=1){
|
||
if(y%400==0||y/400==0&&y/100!=0)
|
||
w[2]=29;
|
||
else
|
||
w[2]=28;
|
||
if(d==1||t==1) {
|
||
count+=2;
|
||
}
|
||
else {
|
||
count++;
|
||
}
|
||
d++;
|
||
t++;
|
||
t%=7;
|
||
if(d>w[m]) {
|
||
m++;
|
||
d=1;
|
||
}
|
||
if(m>12) {
|
||
y++;
|
||
m=1;
|
||
}
|
||
if(y==2020&&m==10&&d==1) {
|
||
count+=2;
|
||
}
|
||
}
|
||
System.out.print(count);
|
||
}
|
||
|
||
}
|