1093. Count PAT ' s (25) "Count"--pat (Advanced level) practise

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.