牛客网PAT练习场-有几个PAT
题目地址:https://www.nowcoder.com/pat/6/problem/4066
题意:求pat->求pa->求p
1 /** 2 * 3 *作者:YCute 4 *时间:2019-12-05-16.02.54 5 *题目题意简单描述:DP,求pat-》先求pa-》求p 6 */ 7 8 9 #include<iostream> 10 #include<cmath> 11 #include<cstring> 12 #include<algorithm> 13 #include<vector> 14 using namespace std; 15 int main(){ 16 int ch; 17 int sum=0; 18 int sum1=0; 19 int sum2=0; 20 while(scanf("%c",&ch)!=EOF){ 21 if(ch=='P'){ 22 ++sum; 23 }else if(ch=='A'){ 24 sum1+=sum; 25 sum1=sum1%1000000007; 26 }else if(ch=='T'){ 27 sum2+=sum1; 28 sum2=sum2%1000000007; 29 } 30 } 31 printf("%d\n",sum2); 32 return 0; 33 }