22年蓝桥杯c++B组

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

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

3,刷题统计

#include 
#include 
#include 
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 
#include 
#include 
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]<

5,X进制减法

#include 
#include 
#include 
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

6,子矩阵

前缀和 枚举 双指针 n^3

7,积木画

费波那西× dp✓

8,扫雷

图的遍历 BFS DFS 哈希表

9,李白打酒

dfs剪枝 dp

10,砍竹子

思维题  贪心  堆

贴一个别人的题解

#include
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair;
using pll = pair;
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 > 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
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。*/

你可能感兴趣的:(c++)