2021暑假集训—个人赛1


A.Find The Array

走你
此题目就是个水题,签到题吧,就是数组里,一定要有该数字减1或者减2,所以只需要从1,一直加2,就是1,3,5等等,无论是多少可以保证,最后的余数都会与前面的某个数差1或者2,满足条件,这就是个等差数列的问题了,可以根据等差数列的公式做

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
const int INF=0x333333f;
const int Max=1000000;
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {int a;
      scanf("%d",&a);
      int b=sqrt(a);
      printf("%d\n",b+(b*b!=a));
    }return 0;
}

B.Maximum Cost Deletion

传送门
题目大意:就是给你一串字符串,删除一个会得到多少分,删除一次会得到多少分,可能为负,就需要你去判断,有种贪心的思想

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
const int INF=0x333333f;
const int Max=110;
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    { int a,b,c,d,i;
      char f[Max];
      scanf("%d%d%d",&a,&b,&c);
      scanf("%s",&f);
      int sum=1;
      d=b+c;
      if(c>0)
      {
          printf("%d\n",d*a);
      }
      else {
              for(i=0;i<a-1;i++)
              {
                  if(f[i]!=f[i+1])
                  {sum++;
                  }
              }
           printf("%d\n",a*b+(sum/2+1)*c);
      }
    }return 0;
}

后面几个题没做,我太菜了,先贴出来,之后会补

C.Manhattan Subarrays

传送门

D.Excellent Arrays

传送门

E.Stringforces

传送门

F.Jumping Around

传送门

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值