蓝桥杯打卡day06(3.9)

墨离 2023-03-08 23:06:06

目录

  • 1.星期计算
  • 2.考勤刷卡
  • 3.打卡

1.星期计算

package lanqiaobei.exe.day05;

public class 数的分解 {
    public static void main(String[] args) {
        int res =  0;
        for(int i = 1; i < 2019;  i++){
            if(!pd(i))continue;
            for(int j = i + 1;  j <= 2019 - i; j ++){
                if(!pd(j))continue;
                for(int k = j + 1; k <= 2019 - j; k++){
                    if (!pd(k))continue;
                    if (i + j + k == 2019){
                        res++;
                    }
                }
            }
        }
        System.out.println(res);
    }

    static boolean pd(int num){
        while(num != 0){
            if(num % 10 == 2 || num % 10 == 4)return false;
            num /= 10;
        }
        return true;
    }
}

2.考勤刷卡

import java.io.*;
import java.util.*

public class 考勤刷卡 {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) throws IOException {
        int n = Integer.parseInt(br.readLine());
        TreeSet<Integer> set = new TreeSet<>();
        while (n -- != 0){
            String[] s = br.readLine().split(" ");
            set.add(Integer.parseInt(s[1]));
        }
        for (int ans:set) System.out.println(ans);

    }
}

3.打卡

import java.util.Scanner;

public class 卡片 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i = 1;;i++){
            if(i * (i + 1) >= 2 * n) {
                System.out.println(i);
                break;
            }
        }
        
    }
}
...全文
16 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

50,779

社区成员

发帖
与我相关
我的任务
社区描述
和众多高校算法内卷分子,一起学习和交流算法那。浓郁的算法交流氛围,拒绝躺平,有效内卷。加入我们,私信我拉你入核心内卷群。
算法数据结构leetcode 个人社区
社区管理员
  • 执 梗
  • Dream-Y.ocean
  • ღCauchyོꦿ࿐
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

 刷题!

试试用AI创作助手写篇文章吧