蓝桥杯百校真题大联赛第5期(一)

A组

卡片

#include <iostream>
using namespace std;

int a[10];

bool check(int x)
{
  while (x)
  {
    if (--a[x % 10] < 0) return false;
    x /= 10;
  }
  return true;
}

int main()
{
  // 请在此输入您的代码
  int i;
  for (i = 0; i <= 9; i ++ ) a[i] = 2021;
  for (i = 1; i; i ++ )
  {
    if (!check(i)) break;
  }
  cout << i - 1 << endl;
  return 0;
}

直线

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

using namespace std;
typedef long long LL;
const int N = 200010;
const double eps = 1e-8;

struct Line
{
    double k, b;
    
    bool operator< (const Line &t) const
    {
        if (fabs(k - t.k) > eps) return k < t.k;
        else return b < t.b;
    }
}l[N];
int cnt, ans;

int main()
{
    for (int x1 = 0; x1 < 20; x1 ++ )
        for (int y1 = 0; y1 < 21; y1 ++ )
        {
            for (int x2 = 0; x2 < 20; x2 ++ )
            {
                if (x2 == x1) continue;
                for (int y2 = 0; y2 < 21; y2 ++ )
                {
                    double k = (double)(y2 - y1) / (x2 - x1);
                    double b = y1 - k * x1;
                    l[cnt ++ ] = {k, b};
                }
            }
        }

    sort(l, l + cnt);
    
    ans = 1;
    for (int i = 0; i < cnt - 1; i ++ )
    {
        if (fabs(l[i].k - l[i + 1].k) > eps || (fabs(l[i].b - l[i + 1].b) > eps))
            ans ++ ;
    }
    
    cout << ans + 20 << endl;
    
    return 0;
}

货物摆放

#include <iostream>
#include <vector>

using namespace std;
typedef long long LL;
const int N = 200010;

vector<LL> d;
LL ans;

int main()
{
    LL n = 2021041820210418;
    for (int i = 1; i <= n / i; i ++ )
        if (n % i == 0)
        {
            d.push_back(i);
            if (i != n / i) d.push_back(n / i);
        }
    
    for (auto& a : d)
        for (auto b : d)
            for (auto c : d)
                if (a * b * c == n)
                    ans ++ ;
    cout << ans << endl;
    
    return 0;
}

B组

乘积尾零

#include <iostream>

using namespace std;
typedef long long LL;
const int N = 200010;

int c1, c2;
LL ans;

int main()
{
    int n = 100;
    for (int i = 0; i < n; i ++ )
    {
        int x;
        cin >> x;
        while (x % 2 == 0)
        {
            c1 ++ ;
            x /= 2;
        }
        while (x % 5 == 0)
        {
            c2 ++ ;
            x /= 5;
        }
    }
    cout << min(c1, c2) << endl;
    
    return 0;
}

第几天

#include <iostream>
using namespace std;
int main()
{
  // 请在此输入您的代码
  cout << 31 + 29 + 31 + 30 + 4 << endl;
  return 0;
}

明码

#include <iostream>
#include <bitset>
using namespace std;
int main()
{
    int n,m;
    while(cin>>n>>m)
    {
        bitset<8> t(n);//创建对象的时候可以直接传进去一个数
        cout<<t.to_string();
        t = m;//也可以直接赋值
        cout<<t.to_string()<<endl;
    }
}
#include <iostream>
#include <cmath>
using namespace std;
typedef long long LL;

int main()
{
    cout << (LL)pow(9, 9) << endl;
    return 0;
}

C组

年号字串

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

using namespace std;
typedef long long LL;

int main()
{
    int n = 2019;
    
    string ans;
    while (n)
    {
        ans += ('A' + n % 26 - 1);
        n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

矩形切割

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

using namespace std;
typedef long long LL;

int main()
{
    int n = 2019, m = 324;
    
    int ans = 0;
    while (n && m)
    {
        if (n < m) swap(n, m);
        n -= m;
        ans ++ ;
    }
    cout << ans << endl;
    return 0;
}

求和

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

using namespace std;
typedef long long LL;
LL ans;

bool check(int x)
{
    while (x)
    {
        int t = x % 10;
        if (t == 2 || t == 0 || t == 1 || t == 9)
            return true;
        x /= 10;
    }
    return false;
}

int main()
{
    int n = 2019;
    for (int i = 1; i <= n; i ++ )
        if (check(i))
            ans += i;
    cout << ans << endl;
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Shirandexiaowo

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

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

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

打赏作者

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

抵扣说明:

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

余额充值