首页 > 其他 > 详细

CF1168B Good Triple 性质分析_好题

时间:2019-05-31 10:40:04      阅读:157      评论:0      收藏:0      [点我收藏+]

Code:

#include<bits/stdc++.h>
#define maxn 1000000 
#define setIO(s) freopen(s".in","r",stdin) 
using namespace std;
int n; 
char str[maxn]; 
int main(){
   //  setIO("input"); 
    int r; 
    scanf("%s",str+1),n=strlen(str+1),r=n+2; 
    long long ans=0; 
    for(int i=n-1;i>=1;--i){
        for(int j=1;i+2*j<=n;++j) {
            if(str[i]==str[i+j]&&str[i+j]==str[i+2*j]) 
            {
                r=min(r,i+2*j); 
                break; 
            } 
        }
        ans += (long long)max(n-r+1,0); 
    }
    cout<<ans<<endl; 
    return 0; 
}

  

CF1168B Good Triple 性质分析_好题

原文:https://www.cnblogs.com/guangheli/p/10953361.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!