# 1.约数问题

``````public class Main {
//    对于一个整数，能整除这个整数的数称为这个数的约数。
//    例如：1, 2, 3, 6 都是 6 的约数。
//    请问 78120 有多少个约数
public static void main(String[] args) {
int yueshu=0;
for(int i=1;i<=78120;i++){
if(78120%i==0){
yueshu++;
}
}
System.out.println("78120有"+yueshu+"个约数");

}
}``````

## 2.跑步训练

``````public class 跑步 {
static int []week={6,7,1,2,3,4,5};//一月一号星期六，依次往后推
static int []months={0,31,28,31,30,31,30,31,31,30,31,30,31};
public static void main(String[] args) {
int ans=0;
int sumday=0;//总天数.用来判断星期几
//年
for(int year=2000;year<=2020;year++){

//判断是否是闰年
if(!check(year)){
//不是闰年就按正常的来
for(int month=1;month<=12;month++){
for(int day=1;day<=months[month];day++){
if(day==1||week[sumday%7]==1)
ans+=2;
else ans++;
sumday++;
}
}
}
//是闰年
else {
if(year==2020){//特判一下2020年因为今年就10个月跑
for (int month = 1; month <= 10; month++) {
if(month==10){
ans+=2;
break;
}
if (month != 2&&month<10) {
for (int day = 1; day <= months[month]; day++) {
if (day == 1 || week[sumday % 7] == 1)
ans += 2;
else ans++;
sumday++;
}
}
else if(month==2){
for (int day = 1; day <= 29; day++) {
if (day == 1 || week[sumday % 7] == 1)
ans += 2;
else ans++;
sumday++;
}
}
}
}
else {
for (int month = 1; month <= 12; month++) {
if (month != 2) {
for (int day = 1; day <= months[month]; day++) {
if (day == 1 || week[sumday % 7] == 1)
ans += 2;
else ans++;
sumday++;
}
} else {
for (int day = 1; day <= 29; day++) {
if (day == 1 || week[sumday % 7] == 1)
ans += 2;
else ans++;
sumday++;
}
}
}

}

}

}
System.out.println(ans);
}
static boolean check(int year){
if((year%4==0&&year%100!=0)||year%400==0){
return true;
}
else return false;
}
}
``````

``````import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Main {

public static void main(String[] args) {
Calendar start = Calendar.getInstance();
Calendar end = Calendar.getInstance();
start.set(2000, Calendar.JANUARY, 1);
end.set(2020, Calendar.OCTOBER, 1);
int res = 0;
do {
System.out.println(new SimpleDateFormat("yyyy-MM-dd").format(start.getTime()));
res += start.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY || start.get(Calendar.DAY_OF_MONTH) == 1 ? 2 : 1;
} while (start.getTimeInMillis() < end.getTimeInMillis());

System.out.println(res);
}
}``````

以上就是我给友友们 准备的两道基础题

祝大家 新的一年offer拿到手软哈哈哈哈

THE END