闲的没事,来道编程,嗨嗨~
题目链接:https://www.luogu.com.cn/problem/P1534 代码实例:
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int day = input.nextInt();
List<Integer> goSchool = new ArrayList(); // 上学上课
List<Integer> goOutCourse = new ArrayList(); // 上补习班上课
int degree = 0; // 不高兴程度
int total = 0; // 不高兴总和
// 输入
for (int i = 0;i < day;i++) {
for (int j = 0;j < 2;j++) {
if(j == 0) {
goSchool.add(input.nextInt());
}else {
goOutCourse.add(input.nextInt());
}
}
}
for (int i = 0;i < day;i++) {
degree = degree + goSchool.get(i) + goOutCourse.get(i) - 8;
total += degree;
}
System.out.println(total);
}
}
|