牛客 Round-72. 小红的01串(二)
原题链接
简单
作者:
YMYS
,
2024-12-16 15:14:11
,
所有人可见
,
阅读 7
/*
* @Author: YMYS
* @Date: 2024-02-25 21:38:22
* @LastEditTime: 2024-12-15 19:01:12
* @FilePath: \VScode-C&C++-Coding\z_demo\try1.cpp
* @URL:https://ac.nowcoder.com/acm/contest/98256/B
* @Description: 小红的01串(二)
*/
#pragma GCC target ("avx")
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
using namespace std;
using namespace __gnu_cxx;
#define FRE_in freopen("D:\\daily_Coding\\VScode-C&C++-Coding\\in.in", "r", stdin)
#define FRE_out freopen("D:\\daily_Coding\\VScode-C&C++-Coding\\out.out", "w", stdout)
#define IOS std::ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define int long long
#define endl '\n'
#define x first
#define y second
#define INF 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define vc vector
typedef pair<int, int> PII;
typedef long long ll;
int gcd(int a, int b){return b ? gcd(b, a % b) : a;}
int lcm(int a,int b){return a*b / gcd(a,b);}
int lcm_of_Array(int arr[], int n) {int lcm = arr[0];for (int i = 1; i < n; ++i) {lcm = (lcm * arr[i]) / gcd(lcm, arr[i]);}return lcm;}
int qmi(int a, int b, int mod){int res=1%mod;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}
int A(int n, int m){int w = 1;while (m--){w = w * n;n -= 1;}return w;}
int C(int n, int m){int w = 1;m = min(m, n - m);for (int i = 1; i <= m; ++i){w = w * (n - m + i) / i;}return w;}
#define len(x) (int)((x).size())
#define out(x...) cout << __LINE__ << ":" << #x << "->";err(x);
void err() {cout << endl;}
template<typename T, typename... U> void err(T arg, U &... args) {cout << arg << " ";err(args...);}
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
// int T;
// void solve(){
// }
const int N = 200000;
int fa(int n){
if(n==1) return 0;
return n*(n-1)/2;
}
signed main()
{
#ifdef ABC
FRE_in;
FRE_out;
#endif
IOS;
// cin>>T;
// while(T--){
// solve();
// }
string str;
cin>>str;
int sum=0;
int len=1;
for(int i=0;i<str.length()-1;i++){
if(str[i] - '0' != str[i+1] - '0'){
len ++ ;
}else{
sum += fa(len);
len = 1;
}
}
if(len>1) sum+=fa(len);
cout<<sum<<endl;
return 0;
}