第十二届蓝桥杯省赛 C/C++ B 组 暴力题解

人们都知道,蓝桥杯B组就是暴力比赛。。。

试题 A: 空间

在这里插入图片描述

1GB=1024MB 1MB=1024KB 1KB=1024B 1B=8b(位)

答案:67108864

cout<<256*1024*1024/4;

试题 B: 卡片

在这里插入图片描述

0-9每个都有2021张,记录每一张的剩余个数,然后从1开始枚举,知道卡片不够用结束,输出当前数字-1。

答案:3181

int main() {
   
   
	map<int,int>x;
	for(int i=0;i<=9;i++)x[i]=2021;
	for(int i=1;;i++){
   
   
		int n=i;
		while(n){
   
   
			if(x[n%10]==0){
   
   
				cout<<i-1<<endl;
				return 0;
			}
			x[n%10]--;
			n/=10;
		}
	}
}

试题 C: 直线

在这里插入图片描述

斜率与截距确定一条直线,枚举出所有的直线,相差超过1e-8(10^ -8)就不是同一条直线了。

答案:40257

#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

const int N = 200000;

int n;
struct Line
{
   
   
    double k, b;
    bool operator< (const Line& t) const
    {
   
   
        if (k != t.k) return k < t.k;
        return b < t.b;
    }
}l[N];

int main()
{
   
   
    for (int x1 = 0; x1 < 20; x1 ++ )
        for (int y1 = 0; y1 < 21; y1 ++ )
            for (int x2 = 0; x2 < 20; x2 ++ )
                for (int y2 = 0; y2 < 21; y2 ++ )
                    if (x1 != x2)
                    {
   
   
                        double k = (double
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值