人们都知道,蓝桥杯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