首页 > 其他分享 >牛客小白月赛91

牛客小白月赛91

时间:2024-05-06 18:11:42浏览次数:13  
标签:cnt int res cin 牛客 小白月赛 91 using mod

A-Bingbong的化学世界

#include<bits/stdc++.h>

using namespace std;
const int maxn = 1001;
int a[maxn];


int main() {
    string t = "...|...";
    vector<string> x(6);
    for (auto &i: x) cin >> i;
    if (x.front() == t) {
        if (x.back() == t) cout << "p";
        else cout << "m";
    } else cout << "o";
    return 0;
}

B-Bingbong的数数世界

#include<bits/stdc++.h>

using namespace std;

void solve(){
    int n;
    cin >> n;
    if( n % 4 == 0 ) cout << "Bong\n";
    else cout << "Bing\n";
}

int main() {
    int TC;
    for (cin >> TC; TC; TC--)
        solve();
    return 0;
}

C-Bingbong的蛋仔世界

#include<bits/stdc++.h>

using namespace std;

using pii = pair<int, int>;


int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n, m, k;
    cin >> n >> m >> k;
    int lx = 1, rx = n, ly = 1, ry = m, mx = n / 2 + 1, my = m / 2 + 1;
    vector<pii> a(k);
    for (auto &[x, y]: a) cin >> x >> y;
    int res = 0;
    for (int dx, dy; not a.empty();) {
        if (lx != mx) lx++, rx--;
        if (ly != my) ly++, ry--;
        vector<pii> b;
        for (const auto &[x, y]: a) {
            if (x == mx and y == my) {
                res++;
                continue;
            }
            if (x != mx and ly <= y and y <= ry) {
                if (x < mx) dx = x + 1;
                else dx = x - 1;
                if (lx <= dx and dx <= rx) b.emplace_back(dx, y);
            } else if (y != my and lx <= x and x <= rx) {
                if (y < my) dy = y + 1;
                else dy = y - 1;
                if (ly <= dy and dy <= ry) b.emplace_back(x, dy);
            }
        }

        a.swap(b);
    }
    cout << res << "\n";
    return 0;
}

D-Bingbong的奇偶世界

#include <bits/stdc++.h>

using namespace std;

using i32 = int32_t;
using i64 = long long;

#define int i64

using vi = vector<int>;

const int mod = 1e9 + 7;


int power(int x, int y) {
    int ans = 1;
    while (y) {
        if (y & 1) ans = ans * x % mod;
        x = x * x % mod, y /= 2;
    }
    return ans;
}

i32 main() {
    string s;
    int n;
    cin >> n >> s;
    int res = 0;
    for (int i = 0, x, cnt = 0; i < n; i++) {
        x = s[i] - '0';
        if (x % 2 == 0) res = (res + cnt + 1) % mod;
        cnt = cnt * 2 % mod;
        if (x != 0) cnt = (cnt + 1) % mod;

    }
    cout << res << "\n";
    return 0;
}

F-Bingbong的幻想世界

做法就是进行拆位,拆位后用前后缀和统计一下每个1 可以产生多少次贡献。

#include<bits/stdc++.h>

using namespace std;

using i32 = int32_t;
using i64 = long long;

#define  int long long

using vi = vector<int>;

const int mod = 1e9 + 7;

i32 main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n;
    cin >> n;
    vector a(20, vi(n + 1));
    for (int i = 1, x; i <= n; i++) {
        cin >> x;
        for (int j = 0; j < 20; j++) {
            if (x & 1) a[j][i] = 1;
            x >>= 1;
        }
    }
    int res = 0;
    for (int l = 0, pre, suf; l < 20; l++) {
        pre = suf = 0;
        int ans = 0;
        for (int i = 1; i <= n; i++)
            if (a[l][i] == 0) suf += (n - i + 1);
        for (int i = 1; i <= n; i++) {
            if (a[l][i] == 0)
                pre += i, suf -= (n - i + 1);
            else
                ans = (ans + pre * (n - i + 1) % mod + i * suf % mod) % mod;
        }
        res = (res + (1ll << l) * ans) % mod;
    }
    cout << res * 2 % mod << "\n";
    return 0;
}

标签:cnt,int,res,cin,牛客,小白月赛,91,using,mod
From: https://www.cnblogs.com/PHarr/p/18175571

相关文章

  • 2024牛客五一集训-1
    CoffeeChicken基本思路:f[i]表示s[i]的字符串长度即f[i]=f[i-2]+f[i]solve(n,k)表示s[n]中第k个字符当n<=2时,直接返回答案当n>2时,k>f[i-2]时solve(n-1,k-f[n-2]);说明要找的字符在前一天中,也就是不在前两天的数据范围之内,因此直......
  • 【牛客】美团2024年春招第一场笔试【技术】
    【牛客】美团2024年春招第一场笔试【技术】1.小美的平衡矩阵#include<iostream>#include<vector>usingnamespacestd;intmain(){intn;cin>>n;vector<vector<int>>nums;for(inti=0;i<n;i++){fgetc(stdin);......
  • 2024 年 5 月 4 日 青年节 周六 多云 常(910 字)
    正文看完了《只有街舞》系列的纪录片。每次看完这种类型的片子,总会激发我许多感触。我总是想书写一个庞大而宏伟的故事,通过故事和人物的行动折射背后深沉的主题。使命感、勇气、选择、放弃、未知、疲惫、克制、时间、迷茫、信念、坚持、自我感动、爱、友情、生活等等等等。每......
  • 牛客小白月赛92 题解
    牛客小白月赛92题解A.获得木头签到\((x\times4)/2\times4=x\times8\)#include<bits/stdc++.h>usingnamespacestd;#definefffirst#definesssecond#definepbpush_back#defineall(u)u.begin(),u.end()#defineendl'\n'#definedebug(x......
  • 牛客 215E 黄魔法师 题解
    Description给出\(n,k\),求一个长度为\(n\)的数组\(a\),满足有恰好\(k\)对数对\((i,j)(1\leqi<j\leqn)\)满足\(a_i+a_j\)为完全平方数。如果不存在,输出\(-1\)。linkSolution显然如果\(k>\binom{n}{2}\)就一定无解。构造时会发现肯定要尽量弄成相同的......
  • P4391 [BOI2009] Radio Transmission 无线传输
    原题链接题解KMP算法的应用。我们知道KMP算法中NEXT数组是当前位置除外的最大前后缀长度。直接抛出结论:ans=cnt-Next[n]证明过程code #include<bits/stdc++.h>usingnamespacestd;constintN=1e6+5;intNext[N];strings;voidNEXT(){intcnt=s.size();......
  • 洛谷题单指南-动态规划2-P1091 [NOIP2004 提高组] 合唱队形
    原题链接:https://www.luogu.com.cn/problem/P1091题意解读:要挑选一个最长的先上升后下降的序列,求其余的元素数量解题思路:先计算正向的最长上升子序列,设f[i]表示以i结尾的正向最长上升子序列再计算逆向的最长上升子序列,设g[i]表示以i结尾的逆向最长上升子序列再枚举所有的i<j,m......
  • AP2917双路输出降压恒流驱动IC 5-100V 12W 摩托车灯照明IC
    AP2917是一款可以一路灯串切换两路灯串的降压恒流驱动器,高效率、外围简单、内置功率管,适用于5-100V输入的高精度降压LED恒流驱动芯片。内置功率管输出最大功率可达12W,最大电流1.2A。AP2917一路灯亮切换两路灯亮,其中一路灯亮可以全亮,可以半亮。AP2917工作频率固定在......
  • 牛客小白月赛88
    A-超级闪光牛可乐#include<bits/stdc++.h>usingnamespacestd;usingf64=double_t;usingi32=int32_t;usingi64=int64_t;usingu64=uint64_t;#defineintlonglongi32main(){cin.tie(nullptr)->sync_with_stdio(false);intx,n;......
  • 芯科SiWx917学习笔记:1-测试Out of Box Demo
    实验目的:测试OutofBoxDemo实验环境:SimplicityStudioV5实验器材:WirelessStarterKitMainboard(BRD4002ARevA06)+ SiWG917SingleBandWi-FiandBLE8MBFlashRadioBoard(BRD4338ARevA01)实验开始:1.新建工程:在demos中找到OutofBoxDemo(SoC)应用演示工程......