1093. Count PAT's (25)
2015-03-14 19:21
267 查看
http://www.patest.cn/contests/pat-a-practise/1093
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 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 may be a huge number, you only have to output the result moded by 1000000007.
Sample Input:
Sample Output:
考试的时候要是能再多给我一分钟提交代码就好了。。。。55555.。。。。。。。。。。。。
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 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 may be a huge number, you only have to output the result moded by 1000000007.
Sample Input:
APPAPT
Sample Output:
2
考试的时候要是能再多给我一分钟提交代码就好了。。。。55555.。。。。。。。。。。。。
#include <iostream> #include <string> using namespace std; int main(){ string s; cin>>s; long long p,pa,pat; p = pa = pat = 0; for(int i = 0;i < s.size();i++){ if(s[i] == 'P') p++; else if(s[i] == 'A'){ pa += p; } else if(s[i] == 'T'){ pat += pa; } } cout<<pat%1000000007; return 0; }
相关文章推荐
- 1093. Count PAT's (25)
- 1093. Count PAT's (25)
- PAT Advanced 1093. Count PAT's (25) 同 PAT Basic 1040
- PAT A 1093. Count PAT's (25)
- PAT (Advanced Level) 1093. Count PAT's (25) 一维动态规划
- PAT 1093. Count PAT's (25)
- 1093. Count PAT's (25)
- 1093. Count PAT's (25)
- 1093. Count PAT's (25)想法题吧,算是排列组合吧
- 1093. Count PAT's (25)水题
- pat 1093. Count PAT's (25)
- ZJU-PAT 1055. The World's Richest (25) 浙大2013年上机复试第二题
- pat 1055. The World's Richest (25)
- PAT 1055. The World's Richest (25)
- PAT (Advanced Level) 1055. The World's Richest (25) 年龄区间内最有钱的人,结构体排序
- PAT: 1055. The World's Richest (25)
- pat 1055. The World's Richest (25)
- 【C++】PAT(advanced level)1055. The World's Richest (25)*
- 浙江大学PAT_甲级_1055. The World's Richest (25)
- 1093. Count PAT's