一、技术总结

  1. 这是一个逻辑题,题目大职意思是可以组成多少个PAT,可以以A为中心计算两边的P和T,然后数量乘积最后相加便是答案。
  2. 还有一个注意的是每次相加后记得mod,取余,不要等到最后加完再取余,会报错可能会溢出。

二、参考代码

#include<iostream>
#include<cstring>
using namespace std;
const int maxn = 100010;
const int inf = 1000000007;
int leftNump[maxn] = {0};
string str;
int main(){
getline(cin, str);
int len = str.length();
for(int i = 0; i < len; i++){
if(i > 0) leftNump[i] = leftNump[i-1];
if(str[i] == 'P'){
leftNump[i]++;
}
}
int ans = 0, rightNumT = 0;
for(int i = len-1; i >= 0; i--){
if(str[i] == 'T') rightNumT++;
else if(str[i] == 'A'){
ans = (ans + leftNump[i] * rightNumT) % inf;
}
}
cout << ans;
return 0;
}

A1093 Count PAT's (25 分)的更多相关文章

  1. PAT甲级 1093 Count PAT‘s (25 分) 状态机解法

    题目 原题链接 The string APPAPT contains two PAT's as substrings. The first one is formed by the 2nd, the ...

  2. 【PAT甲级】1093 Count PAT's (25 分)

    题意: 输入一行由大写字母'P','A','T',组成的字符串,输出一共有多少个三元组"PAT"(相对顺序为PAT即可),答案对1e9+7取模. AAAAAccepted code ...

  3. 1040 有几个PAT (25 分)

    题目链接:1040 有几个PAT (25 分) 做这道题目,遇到了新的困难.解决之后有了新的收获,甚是欣喜! 刚开始我用三个vector数组存储P A T三个字符出现的位置,然后三层for循环,根据字 ...

  4. pat1093. Count PAT's (25)

    1093. Count PAT's (25) 时间限制 120 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CAO, Peng The strin ...

  5. PTA 10-排序5 PAT Judge (25分)

    题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/677 5-15 PAT Judge   (25分) The ranklist of PA ...

  6. PAT 甲级 1075 PAT Judge (25分)(较简单,注意细节)

    1075 PAT Judge (25分)   The ranklist of PAT is generated from the status list, which shows the scores ...

  7. 1025 PAT Ranking (25分)

    1025 PAT Ranking (25分) 1. 题目 2. 思路 设置结构体, 先对每一个local排序,再整合后排序 3. 注意点 整体排序时注意如果分数相同的情况下还要按照编号排序 4. 代码 ...

  8. PAT甲级:1025 PAT Ranking (25分)

    PAT甲级:1025 PAT Ranking (25分) 题干 Programming Ability Test (PAT) is organized by the College of Comput ...

  9. PAT甲级——A1093 Count PAT's【25】

    The string APPAPT contains two PAT's as substrings. The first one is formed by the 2nd, the 4th, and ...

随机推荐

  1. c++用流控制成员函数输出数据

    #include<iostream> #include<iomanip> using namespace std; int main() { ; double b=314159 ...

  2. IDEA springboot配置

    基于springboot2.1.7 springboot项目创建 springboot热部署 springboot配置swagger2 springboot配置mybatis springboot配置 ...

  3. C#开发BIMFACE系列26 服务端API之获取模型数据11:获取单个面积分区信息

    系列目录     [已更新最新开发文章,点击查看详细] 在<C#开发BIMFACE系列25 服务端API之获取模型数据9:获取楼层对应面积分区列表>一文中介绍了如何获取单个模型中单个楼层包 ...

  4. 【Resharper】C# “Simplify conditional ternary expression”

    #事故现场: 对某个对象做空值检测的时候,结合三元运算符给某变量赋值的时候,R#提示:"Simplify conditional ternary expression" : R#建 ...

  5. Vue自定义指令使用方法详解 和 使用场景

    Vue自定义指令的使用,具体内容如下 1.自定义指令的语法 Vue自定义指令语法如下: Vue.directive(id, definition) 传入的两个参数,id是指指令ID,definitio ...

  6. C++入门到理解阶段二基础篇(1)——简介与环境安装

    1.C++ 简介 C++ 是一种静态类型的.编译式的.通用的.大小写敏感的.不规则的编程语言,支持过程化编程.面向对象编程和泛型编程. C++ 被认为是一种中级语言,它综合了高级语言和低级语言的特点. ...

  7. 使用Vuejs 开发chrome 插件的注意事项

    chrome 插件的开发其实并不难,web开发者可以使用 html, css, javascript 轻松的开发实用的 chrome 插件. 一个好的 chrome 插件可以提高我们的开发效率,甚至方 ...

  8. rsync免交互方法

    添加-e "ssh -o StrictHostKeyChecking=no" rsync -avzP -e "ssh -o StrictHostKeyChecking=n ...

  9. Vue中计算属性、侦听、过滤、自定义指令、ref的操作

    1.计算属性 <div id="app"> <input type="text" v-model="x"> < ...

  10. swoole 内存泄露的问题有没有好的办法解决

     在传统的web开发模式中,我们知道,每一次php请求,都要经过php文件从磁盘上读取.初始化.词法解析.语法解析.编译等过程,而且还要与nginx或者apache通信,如果再涉及数据库的交互,还要再 ...