4、格点
题目
本题总分:10 分
问题描述
如果一个点 ( x , y ) 的两维坐标都是整数,即 x ∈ Z 且 y ∈ Z ,则称这个点为一个格点。
如果一个点 ( x , y ) 的两维坐标都是正数,即 x > 0 且 y > 0 ,则称这个点在第一象限。
请问在第一象限的格点中,有多少个点 ( x , y ) 的两维坐标乘积不超过 2021 ,即 x ⋅ y ≤ 2021。
提示:建议使用计算机编程解决问题。
答案提交
这是一道结果填空的题,你只需要算出结果后提交即可。本题的结果为一个整数,在提交答案时只填写这个整数,填写多余的内容将无法得分。
15696
解题思路
x、y双点,
x与y没有固定对应关系,求全部情况,
考虑使用双for循环遍历全部坐标点
代码实现
public class 第12届2题目4 {
public static void main(String[] args) {
// TODO Auto-generated method stub
int n=0;
for (int i = 1; i < 2021; i++) {
for (int j = 1; j < 2021; j++) {
if(i*j<=2021) {
n++;
}
}
}
System.out.println(n);
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/3bef279821e33b80652e03653cad3465.png)
5、整数分解
题目
本题总分:15 分
问题描述
将 3 分解成两个正整数的和,有两种分解方法,分别是 3 = 1 + 2 和 3 = 2 + 1 。注意顺序不同算不同的方法。
将 5 分解成三个正整数的和,有 6 种分解方法,它们是 1 + 1 + 3 = 1 + 2 + 2 = 1 + 3 + 1 = 2 + 1 + 2 = 2 + 2 + 1 = 3 + 1 + 1。
请问,将 2021 分解成五个正整数的和,有多少种分解方法?
答案提交
这是一道结果填空的题,你只需要算出结果后提交即可。本题的结果为一个整数,在提交答案时只填写这个整数,填写多余的内容将无法得分。
解题思路
。。。
5for结束
5for遍历
![](https://i-blog.csdnimg.cn/blog_migrate/b67f5f312ffa895a9a54c04b6eea01ae.png)
计算次数也就这么多吧
结果填空题,。。。暂时不考虑时间了
算了,时间有点长..
R7-6800H接近十分钟出不来答案........考试废了
优化
去一重----
四个数都为1 /四个数和2020
可知道剩下一位数必然是1-2018,实际就是这些可能
还是恐怖呢咋办咋办
c4/2020?
///
五个数字
计算和
分组方法》?》》》!!!》》》》》》》》
2021个人,每五个人一组投多少方法》?
类似之前的,想不起来了哪题....
2021=2021个1
分成五段就是四个间隔???
让四个间隔分开的5组数相加有多少分组方法???
和必然为2021
实际求四个隔板的放置位置可能?????
也就是4个在2020个中的组合可能数量
组合公式
![](https://i-blog.csdnimg.cn/blog_migrate/491bdd571bf34018a3511984bc38ae3f.png)
r为元素个数,n总数 c4/2020
阶乘越界。。。。long也越界
无所谓,大数阶乘会出手,别问麻烦,解决至上
代码实现
大数阶乘
package 轮1省赛11至13;
import java.math.BigInteger;
public class 第12届2题目5 {
public static void main(String[] args) {
System.out.println("1");
BigInteger n = new BigInteger("2020");
BigInteger temp = new BigInteger("1");
BigInteger temp2 = new BigInteger("1");
BigInteger temp3= new BigInteger("2020");
while (!n.equals(temp)) {
n=n.subtract(temp2);
temp3 = temp3.multiply(n);
}
System.out.println("temp3:"+temp3);
//
BigInteger nn = new BigInteger("4");
BigInteger ttemp = new BigInteger("1");
BigInteger ttemp2 = new BigInteger("1");
BigInteger ttemp3= new BigInteger("4");
while (!nn.equals(ttemp)) {
nn=nn.subtract(ttemp2);
ttemp3 = ttemp3.multiply(nn);
}
System.out.println("ttemp3:"+ttemp3);
///
BigInteger nnn = new BigInteger("2016");
BigInteger tttemp = new BigInteger("1");
BigInteger tttemp2 = new BigInteger("1");
BigInteger tttemp3= new BigInteger("2016");
while (!nnn.equals(tttemp)) {
nnn=nnn.subtract(tttemp2);
tttemp3 = tttemp3.multiply(nnn);
}
System.out.println("tttemp3:"+tttemp3);
/
BigInteger count1 = new BigInteger("0");
count1 = ttemp3.multiply(tttemp3);
System.out.println("count1:"+count1);
BigInteger count2 = new BigInteger("0");
count2 = temp3.divide(count1);
System.out.println(count2);
}
}
再次注意
![](https://i-blog.csdnimg.cn/blog_migrate/2fb6a0ee2c616041e60b5fc0733668c3.png)
递减要先给,后给导致如上第一个值乘两遍
6、3的倍数
题目
时间限制: 1.0s 内存限制: 512.0MB 本题总分: 15 分
问题描述
小蓝对 3 33 的倍数很感兴趣。现在他手头有三个不同的数 a , b , c ,他想知道,这三个数中是不是有两个数的和是 3 的倍数。
例如,当 a = 3 , b = 4 , c = 6 时,可以找到 a aa 和 c cc 的和是 3 的倍数。
例如,当 a = 3 , b = 4 , c = 7 时,没办法找到两个数的和是 3 的倍数。
输入格式
输入三行,每行一个整数,分别表示 a , b , c a, b, ca,b,c。
输出格式
如果可以找到两个数的和是 3 33 的倍数,输出 y e s yesyes,否则输出 n o nono。
测试样例1
Input:
3
4
6
Output:
yes
测试样例2
Input:
3
4
7
Output:
no
评测用例规模与约定
对于所有评测用例,1 ≤ a ≤ b ≤ c ≤ 100 。
解题思路
3个数轮流相加,得答案、
代码实现
package 轮1省赛11至13;
import java.util.Scanner;
public class 第12届2题目6 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
if (a+b%3==0||b+c%3==0||a+c%3==0) {
System.out.println("yes");
}else {
System.out.println("no");
}
}
}