文章

26

粉丝

0

获赞

149

访问

6.4k

头像
TAT的个数 题解:统计A左边有几个T,右边有几个T,dp,前缀和
P1646 同济大学机试题
发布于2026年3月11日 11:52
阅读数 150

通过率百分之50原因:int cnt溢出,要用long long;判断一下全为A或全为T的情况。

#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    while(cin>>s)
    {
        long long int cnt=0;
        int len=s.length();
        int lcntT[100005]= {0};
        int rcntT[100005]= {0};
        int l=0;
        while(s[l]!='T') l++;
        if(l>=len){
            cout<<"0"<<endl;
            continue;
        }
        int r=len-1;
        while(s[r]!='T') r--;
        if(r<0){
            cout<<"0"<<endl;
            continue;
  &nb...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发