Topic Information
1093. Count PAT ' s (25)
Time limit MS
Memory Limit 65536 KB
Code length limit 16000 B
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, there was only one line giving a string of no more than 10^5 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 is a huge number, you only has the to output of the result moded by 1000000007.
Sample Input:
Appapt
Sample Output:
2
Thinking of solving problems
Statistics
AC Code
#include <cstdio>#define MOD 1000000007intChintP, a, t, C;intMain () {Long LongCNT =0; while(ch = getchar ()) && ch! =' \ n '){if(ch = =' P ') {++p; }Else if(ch = =' A ') {c + = p; }Else if(ch = =' T ') {++t;        CNT = (cnt + c)%mod; }    }printf("%lld", CNT);return 0;}
 
1093. Count PAT ' s (25) "Count"--pat (Advanced level) practise