Java刷题-----蓝桥杯省赛JavaC组第十二届(第二场)4-------------6

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);

    }

}

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遍历

计算次数也就这么多吧

结果填空题,。。。暂时不考虑时间了

算了,时间有点长..

R7-6800H接近十分钟出不来答案........考试废了

优化

去一重----

四个数都为1 /四个数和2020

可知道剩下一位数必然是1-2018,实际就是这些可能

还是恐怖呢咋办咋办

c4/2020?

///

五个数字

计算和

分组方法》?》》》!!!》》》》》》》》

2021个人,每五个人一组投多少方法》?

类似之前的,想不起来了哪题....

2021=2021个1

分成五段就是四个间隔???

让四个间隔分开的5组数相加有多少分组方法???

和必然为2021

实际求四个隔板的放置位置可能?????

也就是4个在2020个中的组合可能数量

组合公式

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);
    }

    
    }


再次注意

递减要先给,后给导致如上第一个值乘两遍

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");
        }
    }

}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

CLODVEP

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值