22年蓝桥杯c++B组

1, 2*9*9*9+2*9+2=1478

2,歧义4/14 认为都应该给分

3,刷题统计

#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
#define int long long 
signed main()
{
    int n,a,b;
    cin >>a>>b>> n;
    int cnt=0;
    cnt+=(n/(5*a+b*2))*7;
    int cat=(n%(5*a+b*2));
    if(cat>0)cnt++;
    if(cat>a)cnt++;
    if(cat>2*a)cnt++;
    if(cat>3*a)cnt++;
    if(cat>4*a)cnt++;
    if(cat>5*a)cnt++;
    if(cat>5*a+b)cnt++;
    cout << cnt;
}

4, 修剪灌木

#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 1e5;
int a[N];
int main()
{
    int n;
    cin >> n;
    
        for (int i = 1; i <= n; i ++ )
        a[i]=(n-i)*2;
        for (int i = 1; i <= n; i ++ )
        a[i]=max(a[i],a[n+1-i]);
        for (int i = 1; i <= n; i ++ )
        cout << a[i]<<endl;
    
}

5,X进制减法

#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 1e5+10;
#define int long long
int a[N],b[N];
int c[N],d[N];
const int mod= 1000000007;
//贪心
int Solve(int x,int y);
void re(int x,int y);
signed main()
{
    int n;
    int A,B;
    cin >> n;
    cin >> A;
    for (int i = 0; i < A; i ++ )
    cin >> a[i];
    cin >> B;
    for (int i = 0; i < B; i ++ )
    cin >> b[i];
    re(A,B);
    cout << Solve(A,B);
}
//贪心
int Solve(int x,int y)
{
    int z=max(x,y);
    int cnt=0;
    int flag=1;
    for (int i = 0; i < z; i ++ )
    {
        if(a[i]==0&&b[i]==0)
        c[i]=2;
        else
        c[i]=max(a[i],b[i])+1;
    }
    for (int i = 0; i<z; i++ )
    {
        //cout << c[i]<<endl;
        cnt+=flag*(a[i]-b[i]);
        flag*=c[i];
        flag%= 1000000007;
        cnt%= 1000000007;
    }
    return cnt;
}
void re(int x,int y)
{
    for (int i = 0; i < x; i ++ )
    d[i]=a[i];
    for (int i = 0; i < x; i ++ )
    a[i]=d[x-i-1];
    for (int i = 0; i < y; i ++ )
    d[i]=b[i];
    for (int i = 0; i < y; i ++ )
    b[i]=d[y-i-1];
}

6,子矩阵

前缀和 枚举 双指针 n^3

7,积木画

费波那西× dp✓

8,扫雷

图的遍历 BFS DFS 哈希表

9,李白打酒

dfs剪枝 dp

10,砍竹子

思维题  贪心  堆

贴一个别人的题解

#include<bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using db = double;


static int stream_off = []() {
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    return 0;
}();//关闭流同步,注意不要和c式输入同时使用(如快读板子)

ll fuc(ll x) {
    return sqrt(x / 2 + 1);
}

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    vector<vector<ll> > v(n);
    for (int i = 0; i < n; ++i) {
        ll x;
        cin >> x;
        while (x > 1) {
            v[i].push_back(x);
            x = fuc(x);
        }
        reverse(v[i].begin(), v[i].end());
    }
    for (int step = 0; step < 7; ++step) {
        ll rear = -1;
        for (auto& x : v) {
            if (x.size() <= step) {
                rear = -1;
                continue;
            }
            if (x[step] != rear) ++ans;
            rear = x[step];
        }
    }
    cout << ans;
    return 0;
}
/*
作者:梦璃夜天星
链接:https://www.acwing.com/solution/content/47620/
来源:AcWing
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。*/

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值