https://codeforces.com/contest/1096/problem/B

题解:只要数前后相同个数,再看头尾是不是相同

/*
*@Author:   STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=210000;
const int MOD=998244353;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,q;
char str[N];
int main()
{
#ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout);
#endifscanf("%d",&n);scanf("%s",str);ll ans=0;int a=0;int b=0;for(int i=0;i<n;i++){if(str[i]==str[0]){a++;}else{break;}}for(int j=n-1;j>=0;j--){if(str[j]==str[n-1]){b++;}else{break;}}if(str[0]==str[n-1]){ans=(1ll*(a+1)*(b+1))%MOD;}else{ans=(a+b+1)%MOD;}cout << ans << endl;//cout << "Hello world!" << endl;return 0;
}

Substring Removal相关推荐

  1. Educational Codeforces Round 93 (Rated for Div. 2) 题解

    目录 A.CF1398A Bad Triangle(模拟) B.CF1398B Substring Removal Game(贪心) C.CF1398C Good Subarrays(映射) D.CF ...

  2. Educational Codeforces Round 93 (Rated for Div. 2)

    A - Bad Triangle 选出三个序列使之不能组成三角形.先把差距最大的选了,枚举中间值.两边之和不大于第三边. #define IO ios::sync_with_stdio(false); ...

  3. Educational Codeforces Round 57 (Rated for Div. 2)

    我好菜啊. A - Find Divisible 好像没什么可说的. #include<cstdio> #include<cstring> #include<algori ...

  4. 20190919CF训练

    A.Border 给你一堆数字,你可以从这些数字取出任意多个组合成一个新的数字,问你这个新的数字在k进制下的最后一位一共有多少种情况 首先考虑k进制下的最后一位是这个数字对k取余,然后有一个扩展贝祖定 ...

  5. 深入了解bash与sh的区别

    在我们所使用的系统当中,使用sh调用执行脚本,相当于打开了bash的POSIX标准模式 (等效于bash的 --posix 参数) 一般的,sh是bash的"子集" (不是子集的部 ...

  6. kafka(1.1版本)源码阅读记——深入kafka-server-start.sh脚本

    本例中使用非守护进程模式,与守护进程模式的比较会在后面介绍 Kafka集群的启用只需要通过./kafka-server-start.sh ../config/server.properties来进行, ...

  7. 【CF套题】Educational Codeforces Round 57

    [前言] 打了小号,做到心态爆炸,虽然最后过了6T. 然而十分后悔为什么没有用大号打,大号打就上橙了qwq. [题目] 原题地址 A.Find Divisible 输出lll和2l2l2l即可. #i ...

  8. Java substring使用时有哪些注意事项?

    首先,使用substring截取字符串时,可能会出现两种异常,分别是StringIndexOutOfBoundsException和NullPointerException. 即字符串索引越界异常 与 ...

  9. leetcode 30. Substring with Concatenation of All Words 与所有单词相关联的字串 滑动窗口法

    题目描述 给定一个字符串 s 和一些长度相同的单词 words.在 s 中找出可以恰好串联 words 中所有单词的子串的起始位置. You are given a string, s, and a ...

最新文章

  1. setTimeOut()和setInterval()的用法
  2. sleep interrupted异常_Java高并发3中断线程以及isInterrupted与interrupted区别
  3. 《C语言编程初学者指南》一1.9 本章小结
  4. ES6的字符串与正则表达式
  5. java中输出时间12小时制转换为24小时制显示
  6. 我所知道的几种display:table-cell的应用
  7. Visual Studio—— IntelliSense: #error 指令: Please use the /MD switch for _AFXDLL builds
  8. 【codevs1690】开关灯,线段树练习
  9. Java时间处理方法
  10. Appium原理初步--Android自动化测试学习历程
  11. java代码反编译 工具下载及注意事项 xjad下载
  12. 【算法练习】82.重复的DNA序列——哈希表
  13. IIC详解之AT24C08
  14. PetaLinux学习笔记 3
  15. 视频分配器的特点以及应用
  16. book mac pro怎么重装系统_苹果13英寸新MacBook Pro怎么重装win7系统
  17. 程序员的情怀《从前慢》木心
  18. 小程序影藏溢出的gif_视频转gif怎么弄?视频片段转动图 将影视片段制作成微信表情包的方法~...
  19. WORD页码相同问题
  20. MATLAB数字图像水印

热门文章

  1. struts2漏洞监测_CVE20190233: S2060 拒绝服务漏洞分析
  2. Java中给循环体起别名
  3. mysql怎么删除唯一索引_mysql删除唯一索引
  4. python创建excel图表_Python:使用图表创建Excel工作表
  5. stata面板数据gmm回归_【stata】面板GMM估计
  6. 山西省职高计算机分数线,2020年山西五年制高职和普通中专录取分数线
  7. 毕业了,在Python中使用 OpenCV 和K-Means 聚类对毕业照进行图像分割
  8. 七十四、滑动窗口最值问题
  9. 十一、Spark Streaming和Kafaka
  10. EnvironmentError: [WinError 5] 拒绝访问