找出数据结构

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 100001;
string str;
int s,sj,g;
int ans;
signed main(){
    ios::sync_with_stdio(0);
    getline(cin,str);
    int len = str.size();
    for(int i = 0; i < len; i++)
        if(str[i] == 'G') g++;
    for(int i = 0; i < len; i++){
        if(str[i] == 'G') g--;
        if(str[i] == 'S') s++;
        if(str[i] == 'J'){
            ans = (ans + sj * g) % mod;
            sj += s;
        }
    }
    cout << ans;
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/xcfxcf/p/12628815.html