摘要: 大致题意就是判断给出序列中,哪些元素是主元,即主元元素大于等于其左边的最大值,小于等于其右边的最小值。 例如,1 , 3, 2, 4, 5 1<=1 <=2,所以1是主元。 4<=4<=5,所以4是主元。 5<=5<=INF,所以5是主元。 坑点:输出结束后,必须加一个换行符,不然测试点2显示格式错 阅读全文
posted @ 2020-02-19 21:20 tangq123 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 这又是一道hash题。。。 注意点: 地球文如果是13的倍数,那么转换成火星文只输出一个单词,比如 13 要输出 tam; 同样,如果火星文是13的倍数,也只会给出一个单词,比如tam,转换成地球文后输出是13。 #include<iostream> #include<algorithm> usin 阅读全文
posted @ 2020-02-19 20:43 tangq123 阅读(274) 评论(0) 推荐(0) 编辑
摘要: 水题。还是一道hash题。 #include<iostream> using namespace std; int main() { int map[128] = {0}; char c; while (scanf("%c",&c) != EOF) map[c]++; while (map['P'] 阅读全文
posted @ 2020-02-19 18:25 tangq123 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 水题,又是一道hash题。 #include<iostream> #include<cctype> using namespace std; int hashtable[26]= {0}; int main() { char c; while(scanf("%c",&c)!=EOF) { if(is 阅读全文
posted @ 2020-02-19 18:03 tangq123 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 水题。发现PAT考察hash很多。 #include<iostream> #include<unordered_map> using namespace std; struct Student { string id;//学号 int sitNum;//考试座位号 }; int main() { i 阅读全文
posted @ 2020-02-19 17:55 tangq123 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 分析: PPPATTTTPAT 第一个A的左边有3个P,右边有5个T,此时PAT共有15个。 第二个A的左边有4个P,右边有1个T,此时PAT共有4个。 这个字符串包含的PAT总共有19个。 总结,只要知道每个A的左边共有m个P,右边共有n个T,此时PAT的个数位即为m*n; #include<io 阅读全文
posted @ 2020-02-19 12:26 tangq123 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 较水。 #include<iostream> using namespace std; int hashtable1[300] = {0},hashtable2[300]= {0}; int main() { string str1,str2; cin>>str1>>str2; for(int i 阅读全文
posted @ 2020-02-19 12:13 tangq123 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 水题。 #include<iostream> using namespace std; int hashtable[111]= {0}; //成绩与人数的映射 int main() { int n,score,k; cin>>n; for(int i = 0; i < n; ++i) { scanf 阅读全文
posted @ 2020-02-19 12:11 tangq123 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 水题。 #include<iostream> #include<algorithm> using namespace std; typedef long long LL; int main() { LL G1,S1,K1,G2,S2,K2; scanf("%lld.%lld.%lld %lld.%l 阅读全文
posted @ 2020-02-19 12:10 tangq123 阅读(76) 评论(0) 推荐(0) 编辑
摘要: 水题。 #include<iostream> #include<cmath> using namespace std; int main() { int n,m; char c; cin>>n>>c; m = round(n/2.0)-2;//行数 for(int i =0; i< n; ++i)/ 阅读全文
posted @ 2020-02-19 12:09 tangq123 阅读(115) 评论(0) 推荐(0) 编辑