C++小白练习第七天

[复制链接]
发表于 2026-1-18 19:39:45 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
C++小白练习第七天

以下为牛客挑衅
本日劳绩
  1. 回顾了二分答案了,对于一个确定的答案的区间,我们可以直接进行二分答案就行了
  2. while(l<r){
  3.         int mid=l+r>>1;
  4.         if(check(mid)){
  5.             r=mid;
  6.         }else{
  7.             l=mid+1;
  8.         }
  9.     }
  10. 可以用for(int i=1;i<=n;i++){
  11.         cin>>s[i];
  12.         if(s[i]==s[i-1]){
  13.             pr[i]=pr[i-1];
  14.         }else{
  15.             pr[i]=i-1;
  16.         }
  17.     }
  18. 处理一段连续区间最后a[i]个数相同的个数。
  19. j=i-s[i]+1
复制代码
牛客小白月赛127

Flower_Rainbow_and_You

A-Flower_Rainbow_and_You_牛客小白月赛127
  1. 1 2 3 4 5 6 7
复制代码
  1. Violet
复制代码
解题代码

[code]#include#define int long long#define lll __uint128_t#define PII pair#define endl '\n'using namespace std;#define yn(ans) printf("%s\n", (ans)?"Yes":"No");//快速打印#define YN(ans) printf("%s\n", (ans)?"YES":"NO");#define REP(i, e) for (int i = 0; i < (e); ++i)#define REP1(i, s, e) for (int i = (s); i > t; while (t--)#define TESTconst int N=2e5+10,M=1e3+10,mod=1e9+7;int a[N],b[N],c[N],pre[N];signed main(){        std::ios::sync_with_stdio(false);    cin.tie(0);    cout.tie(0);    string s[7] = {"Red", "Orange", "Yellow", "Green", "Blue", "Indigo", "Violet"};    int m=0;    int ma=-1;    for(int i=0,x;i>x;        if(x>ma){            m=i;            ma=x;        }    }    cout>k;    vectorm(N,0);    for(int i=0,x;i>x;        m[x%k]++;    }    for(int i=0;i
回复

使用道具 举报

登录后关闭弹窗

登录参与点评抽奖  加入IT实名职场社区
去登录
快速回复 返回顶部 返回列表