第十四届蓝桥杯三月真题刷题训练——第 6 天

第 1 题:星期计算

签到

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

public class Main {

    static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    
    public static void main(String[] args) throws Exception {

//    	out.println((int)(Math.pow(20, 22) % 7));
    	out.println(7);

        out.flush();
        in.close();
    }  
}

第 2 题:考勤刷卡

TreeSet

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

public class Main {

    static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    
    public static void main(String[] args) throws Exception {
    	
    	TreeSet<Integer> set = new TreeSet<>();

    	int n = Integer.parseInt(in.readLine());
    	for (int i = 0; i < n; i++) {
    		String[] s = in.readLine().split(" ");
    		set.add(Integer.parseInt(s[1]));
    	}
    	for (int num: set) {
    		out.println(num);
    	}

        out.flush();
        in.close();
    }  
}

第 3 题:卡片

二分

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

public class Main {

    static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    
    static int n;
    public static boolean check(int x) {
    	long sum = (long)(x + 1) * x / 2;
    	return sum >= n;
    }
    
    public static void main(String[] args) throws Exception {
    	
    	n = Integer.parseInt(in.readLine());
    	
    	int l = 1, r = n; 
    	while (l < r) {
    		int mid = l + ((r - l) >> 1);
    		if (check(mid)) {
    			r = mid;
    		} else {
    			l = mid + 1;
    		}
    	}
    	
    	out.println(l);

        out.flush();
        in.close();
    }  
}

第 4 题:最大子矩阵
明天写

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值