今天去申请了个东西,用了多半天,回来还补作业,还要看编译,连着两天上扛不住了,今天先写俩了,板块一兄弟们根据情况自己写吧,不会了回去翻一下我原来写的
板块一:之前做过的历届真题的复习
更题解可以用一两句话带过,主要记录再刷之后的心得,比如用到的知识点或者自己大意的地方
1、空间(21年省赛——3月14日) https://www.lanqiao.cn/problems/1445/learning/
2、等差数列(19年省赛——3月12日) https://www.lanqiao.cn/problems/192/learning/
3、回文日期(20年省赛——3月9号) https://www.lanqiao.cn/problems/498/learning/
4、青蛙跳杯子(17年省赛——3月18日)http://lx.lanqiao.cn/problem.page?gpid=T2835 (先登录蓝桥账号,这题在训练系统中)
板块二:今日练习
成绩统计(20年省赛)
题目链接: https://www.lanqiao.cn/problems/502/learning/
这一题直接统计就行,使用
Math.round
四舍五入
import java.util.Scanner;
public class Main {
static final int N = 10010;
static int[] a = new int[N];
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
double good = 0, pass = 0;
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
if (a[i] >= 60) pass++;
if (a[i] >= 85) good++;
}
sc.close();
System.out.println(Math.round((pass / n) * 100) + "%");
System.out.println(Math.round((good / n) * 100) + "%");
}
}
既约分数(20年省赛)
题目链接: https://www.lanqiao.cn/problems/593/learning/
还是一样,直接全部遍历,然后判断分子和分母的最大公约数的值是不是1就行了,注意不要直接用质数去拼,我第一次直接计算出质数去做的,然后才发现8/9也是满足条件的,但是两个都不是质数
答案:2481215
package year2020A;
/**
* http://oj.ecustacm.cn/problem.php?id=1509
*
* @author Jia
*
*/
public class exercise2 {
public static void main(String[] args) {
int ans = 0;
int end = 2021;
for (int i = 1; i < end; i++) {
for (int j = 1; j < end; j++) {
if (gcd(i, j) == 1) {
ans++;
}
}
}
System.out.println(ans);
}
/**
* 求最大公约数
*
* @param i
* @param j
* @return
*/
private static int gcd(int i, int j) {
return i % j == 0 ? j : gcd(j, i % j);
}
}