麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

1093. Count PAT's (25)

2019-11-14 08:55:01
字體:
供稿:網(wǎng)友

The string APPAPT contains two PAT’s as substrings. The first one is formed by the 2nd, the 4th, and the 6th characters, and the second one is formed by the 3rd, the 4th, and the 6th characters.

Now given any string, you are supposed to tell the number of PAT’s contained in the string.

Input Specification:

Each input file contains one test case. For each case, there is only one line giving a string of no more than 105 characters containing only P, A, or T.

Output Specification:

For each test case, PRint in one line the number of PAT’s contained in the string. Since the result may be a huge number, you only have to output the result moded by 1000000007.

Sample Input: APPAPT Sample Output: 2

#include<cstdio>#include<cstring>const int maxn=100010;const int MOD=1000000007;char a[maxn];int leftNumP[maxn]={0};int main(){ scanf("%s",a); int len=strlen(a); for(int i=0;i<len;i++){ if(i>0){ leftNumP[i]=leftNumP[i-1]; } if(a[i]=='P') leftNumP[i]=leftNumP[i-1]+1; } int cntt=0,ans=0; for(int i=len-1;i>=0;i--){ if(a[i]=='T') cntt++; if(a[i]=='A'){ ans=(ans+leftNumP[i]*cntt)%MOD; } } printf("%d/n",ans);// long long cnt=0;// for(int i=0;i<len;i++){// if(a[i]=='P'){// for(int j=i+1;j<len;j++){// if(a[j]=='A'){// for(int k=j+1;k<len;k++){// if(a[k]=='T'){// cnt++;// }// }// }// }// }// }// long long cnt=0,cntp=0;// for(int i=0;i<len;i++){// if(a[i]=='P') cntp++;// if(a[i]=='A'){// long long cntt=0;// for(int j=i+1;j<len;j++){// if(a[j]=='T') cntt++;// }// cnt=(cnt+cntp*cntt)%MOD;// }// }// printf("%lld/n",cnt); return 0;}
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 狠狠干夜夜草 | 国产一有一级毛片视频 | 日韩在线播放第一页 | 日本娇小18xxxⅹhd | 一区二区久久 | 91短视频在线免费观看 | 午夜视频在线免费观看 | 99在线免费观看视频 | 久久蜜桃精品一区二区三区综合网 | www.91在线| 91av大片| 黄色免费影片 | 欧美性生活久久久 | 在线观看视频亚洲 | 日韩精品一区二 | 男人的天堂视频网站 | 国产精品91在线 | 午夜精品区 | av在线不卡免费 | 性欧美极品xxxx欧美一区二区 | 99在线精品视频免费观看20 | 国产精品久久久久久久久久 | 久草在线公开视频 | 成人毛片在线免费看 | 国产免费一区二区三区最新不卡 | 国产手机国产手机在线 | 久久99精品久久久久久秒播蜜臀 | 亚洲无av| 91一区二区在线观看 | 精精国产xxxx视频在线播放7 | 久久精品中文字幕一区二区三区 | 精品国产一区二区三区四区在线 | 黄色视频一级毛片 | 欧美日韩在线播放 | 欧洲精品久久 | 精品一区二区久久久久久按摩 | 久久久久久久爱 | 欧美成人一区二区三区 | 久久伊人精品视频 | 宅男噜噜噜66国产在线观看 | 久综合 |