The string appapt contains and the other PAT' s as substrings. The first one is formed by the 2nd, the 4th, and the 6th characters, and the second one are formed by the 3rd, the 4th, and the 6th characters.
Now given any string, you is supposed to tell the number of PAT's contained in the string.
Input Specification:
Each input file contains the one test case. For each case, the there is only one line giving a string of no further than 105characters 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 is a huge number, you only has the to output of the result moded by 1000000007.
Sample Input:
Appapt
Sample Output:
2
1#include <string>2#include <iostream>3#include <map>4 5 using namespacestd;6 7 intnumofp[100001];8 intnumofpa[100001];9 intMain ()Ten { One stringstr; A getline (CIN,STR); - intp,a,t; -T =0; the intSUMOFP =0; - for(inti =0; I < str.length (); + +i) - { - if(Str[i] = ='P') +++SUMOFP; -Numofp[i] =SUMOFP; + } A at intSUMOFPA =0; - for(inti =0; I < str.length (); + +i) - { - if(Str[i] = ='A') - { -SUMOFPA + =Numofp[i]; in } -Numofpa[i] =SUMOFPA; to } + - intSumofpat =0; the for(inti =0; I < str.length (); + +i) * { $ if(Str[i] = ='T')Panax Notoginseng { -Sumofpat + =Numofpa[i]; theSumofpat = sumofpat%1000000007;//Pit Point + } A } thecout << Sumofpat <<Endl; + return 0; -}
1093. Count PAT ' s (25)