摘要: 前n个素数的求法:埃氏筛 leetcode204:https://leetcode-cn.com/problems/count-primes/ 算法笔记5.4 素数也叫做质数 #include <iostream> #include<map> #include<string> #include<cs 阅读全文
posted @ 2021-02-11 22:55 TR_Goldfish 阅读(43) 评论(0) 推荐(0) 编辑
摘要: 质数也叫素数 阅读全文
posted @ 2021-02-11 21:23 TR_Goldfish 阅读(115) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include<map> #include<string> #include<cstdio> using namespace std; int main() { map<string,int>str; int n,m; scanf("%d %d",&n,&m 阅读全文
posted @ 2021-02-11 21:06 TR_Goldfish 阅读(60) 评论(0) 推荐(0) 编辑
摘要: C++ map中key值存在情况判定 1、count函数 count函数用于统计key值在map中出现的次数,map的key不允许重复,因此如果key存在返回1,不存在返回0 if (testMap.count(key) == 0) cout << "no this key" << endl; 2、 阅读全文
posted @ 2021-02-11 20:55 TR_Goldfish 阅读(750) 评论(0) 推荐(0) 编辑
摘要: sort()—排序函数 有一说一和Golang的sort好像啊!! 给出传送门: leetcode973 Package sort中Slice,SliceStable的用法 顾名思义,sort就是用来排序的函数,它根据具体情形使用不同的排序算法,效率很高。一般来说,不推荐C语言中的qsort函数,原 阅读全文
posted @ 2021-02-11 05:14 TR_Goldfish 阅读(316) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include<cstdio> #include<string> using namespace std; int main() { string str; getline(cin,str); int len=str.size(); for(int i=le 阅读全文
posted @ 2021-02-11 04:55 TR_Goldfish 阅读(28) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include<cstdio> #include<vector> using namespace std; int main() { int a,b,c,d; scanf("%d %d %d",&a,&b,&c); int sum=a+b; vector<i 阅读全文
posted @ 2021-02-11 04:47 TR_Goldfish 阅读(67) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include<cstdio> #include<map> using namespace std; int main() { int num=0; char chr; scanf("%d %c",&num,&chr); int row = (num/2)+ 阅读全文
posted @ 2021-02-11 04:14 TR_Goldfish 阅读(42) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include<cstdio> #include<map> using namespace std; int main() { map<int,int>mp; int len; scanf("%d",&len); int j=0; for (int i=0; 阅读全文
posted @ 2021-02-11 03:55 TR_Goldfish 阅读(41) 评论(0) 推荐(0) 编辑
摘要: 题目有问题,前面说了数据不大于10^5设置数组为100010却报错,20010却对了。。。无语,系统bug 为了用事实说明挖掘机技术到底哪家强,PAT 组织了一场挖掘机技能大赛。现请你根据比赛结果统计出技术最强的那个学校。 输入格式: 输入在第 1 行给出不超过 10^5 的正整数 N,即参赛人数。 阅读全文
posted @ 2021-02-11 03:22 TR_Goldfish 阅读(96) 评论(0) 推荐(0) 编辑
摘要: 注意: getline()函数会把最后一个字符(回车键'/n')读入,但在存区时只会保存空字符('/0') #include <iostream> #include <string> using namespace std; int main() { string str; getline(cin, 阅读全文
posted @ 2021-02-11 02:23 TR_Goldfish 阅读(50) 评论(0) 推荐(0) 编辑
摘要: ctrl+shift+c可以快速注释掉多行。 ctrl+shift+x可以取消注释,才发现,哈哈真方便。 阅读全文
posted @ 2021-02-11 01:42 TR_Goldfish 阅读(345) 评论(0) 推荐(0) 编辑