找回密码
 立即注册
首页 业界区 安全 C++小白训练第七天

C++小白训练第七天

谯梨夏 2026-1-18 22:40:01
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.png
  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

相关推荐

2026-1-21 19:44:47

举报

2026-2-2 08:19:13

举报

2026-2-8 05:00:59

举报

2026-2-9 15:18:39

举报

2026-2-10 14:03:41

举报

12下一页
您需要登录后才可以回帖 登录 | 立即注册