- 博客(28)
- 收藏
- 关注

原创 刷题随记 洛谷P1217 [USACO1.5]回文质数 Prime Palindromes 回文数与质数的处理思想
洛谷 P1217 [USACO1.5]回文质数 Prime Palindromes. 找回文数 问题描述: 回文数不好构造,但可以利用函数进行判断该数是否为回文数 错误示范 for (d1 = 1; d1 <= 9; d1+=2) { // 只有奇数才会是素数 for (d2 = 0; d2 <= 9; d2++) { for (d3 = 0; d3 <= 9; d3++) { palindrome = 10000*d1 + 100
2021-07-31 21:56:55
106
原创 结构体排序之运算符重载与STL的应用
struct point { int elem; bool operator==(const point b) const { return this->elem == b.elem; } bool operator!=(const point b) const { return this->elem != b.elem; } bool operator<=(const point b) const { return this->elem <= .
2022-04-06 11:42:13
153
原创 二分法模板集合
二分法模板二分查找核心二分答案核心 二分查找 find_x(a[], x) { left = 0, right = a.length - 1; while left <= right mid = (left + right) / 2; if a[mid] == x return mid; else if a[mid] < x left = mid + 1; else
2022-04-03 10:46:38
334
原创 字符串常用函数讲解及演示集合
字符串常用操作STL集合 字符串全复制字符串半复制字符串连接字符串按字节比较字符串长度计算字符匹配字符串匹配参考资料 字符串全复制 /* strcpy example */ #include <stdio.h> #include <string.h> int main () { char str1[]="Sample string"; char str2[40]; char str3[40]; strcpy (str2,str1); strcpy (str3,"
2022-04-02 15:02:17
330
原创 strcat 字符串连接
strcat ( destination, source ); definition char * strcat ( char * destination, const char * source ); function 复制source字符串添加到destination中。目标字符串中的终止空字符( ‘\0’ )被source的第一个字符覆盖,并且在destination中两者连接形成的新字符串的末尾包含一个空字符。 Parameters destination Pointer to the de
2022-04-02 13:58:40
397
原创 strcpy 字符串复制
strcpy definition char * strcpy ( char * destination, const char * source ); function Copy string 字符串复制 Parameters destination Pointer to the destination array where the content is to be copied. source C string to be copied. Example code #include
2022-04-02 13:17:54
245
原创 线性筛素数模板
#include<bits/stdc++.h> using namespace std; const int MAX_N = 1e8+9; int prime[MAX_N]; bool isprime[MAX_N]; int n,q,point; int top=0; void get_prime(int n) { memset(isprime,true,sizeof(isprime)); for(int i=2;i<=n;i++) { if(isprime[i]) {
2022-03-30 19:31:52
76
原创 快速幂||取余运算模板
求b的p次幂模mod #include<bits/stdc++.h> using namespace std; long long n; long long pow(long long b,long long p,long long mod) { long long res=1; while(p) { if(p&1) { res=(res*b)%mod; } b=(b*b)%m
2022-03-30 15:41:46
287
原创 堆优化单源最短路标准模板
#include<iostream> #include<cstdio> #include<cstring> #include<set> using namespace std; typedef pair<int,int> PII; const int MAX_N=100010; const int MAX_M=200010; int n,m,s,u,v,l,bh; int p[MAX_N],dis[MAX_N]; bool vis[MAX_N];
2022-03-30 12:02:57
105
转载 刷题随记 转载 洛谷P1601 A+B Problem(高精)标准简洁的高精写法
洛谷 P1601 A+B Problem(高精). 比较简单的高精度。 高精度。顾名思义,就是在很大的位数情况下进行运算。(炸int) 其基本思想就是用数组进行模拟加法。 模拟近位。 最后遍历数组输出。 附上高精加,减,乘代码。 减,乘被注释。 自行取用修改 #include<stdio.h> #include<string> #include<string.h> #include<iostream> using namespace std; //co
2021-08-16 14:37:46
168
原创 刷题随记 洛谷P1042 [NOIP2003 普及组] 乒乓球 边界约束错误,不要用一个点来约束,尽可能以区间的形式约束
洛谷P1042 [NOIP2003 普及组] 乒乓球. 第一次错误代码 #include<bits/stdc++.h> using namespace std; string a,c; int l,r; int len; int main() { while(cin>>c) { a=a+c; } len=a.length(); for(int i=0;i<len;i++) { if(a[i]=='W') { l++; if(l==11)
2021-08-14 21:46:32
286
原创 刷题随记 洛谷P5740 【深基7.例9】最厉害的学生 复制粘贴时变量名未改
QAQ错误的原因和上次一样 洛谷P5740 【深基7.例9】最厉害的学生 第一次错误代码 #include<bits/stdc++.h> using namespace std; int n; struct jgt{ string name; int ch; int ma; int en; int sum; }a[1009]; bool pd(int x,int y) { if(abs(a[x].ch-a[y].ch)<=5&&abs(a[x].ma-a[y]
2021-08-14 21:04:20
210
原创 刷题随记 洛谷P5740 【深基7.例9】最厉害的学生 RE错误积累二 无返回值
洛谷P5740 【深基7.例9】最厉害的学生. 第一次错误代码 #include<iostream> #include<bits/stdc++.h> using namespace std; int n; struct jgt{ string name; int ch,ma,en,num,sum; }a[1009]; struct Roule1{ bool operator ()(const jgt &s1,const jgt &s2) { if(s1.
2021-08-14 20:48:32
333
原创 刷题随记 洛谷P5736 【深基7.例2】质数筛 未考虑 1 是否为质数
洛谷P5736 【深基7.例2】质数筛. 第一次错误代码 #include<iostream> #include<cstring> #include<cstdio> #include<cmath> using namespace std; int n,top=0; int a; int prime[100009]; bool is_prime[100009]; void get_prime(int n) { memset(is_prime,true,siz
2021-08-14 20:27:55
224
原创 刷题随记 洛谷P1177 【模板】快速排序 手打递归快排为啥比STLsort慢
P1177 【模板】快速排序. 超时代码 #include<iostream> #include<cstdio> #include<cstring> using namespace std; int n; int a[100000+9]; void qsort(int a[],int l,int r) { if(l>=r) return ; //1 int i=l,j=r,k=a[l]; while(i!=j) { while(j>i&am
2021-08-14 20:15:04
190
原创 刷题随记 洛谷P1200 [USACO1.1]你的飞碟在这儿Your Ride Is Here 复制粘贴时变量名未改
洛谷P1200 [USACO1.1]你的飞碟在这儿Your Ride Is Here. 第一次错误代码 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; char a[100],b[100]; long long num_a=1,num_b=1; int main() { cin>>a>>b;
2021-08-14 02:16:03
173
原创 刷题随记 洛谷P1597 语句解析 char字符用作数组下标时忘记转换
洛谷P1597 语句解析. 第一次错误代码 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int len=0; int state; char ch[300]; int ans[5]; int main() { gets(ch); len=strlen(ch); for(int i=0;i<len;i+
2021-08-14 02:11:42
233
原创 刷题随记 洛谷P1957 口算练习题 求10进制数有多少位(不含小数)
P1957 口算练习题. 第一次错误代码 #include<bits/stdc++.h> using namespace std; int n; int ans; int a,b; char c; int len(int x) { int l=0; if(x<0) l++; while(x) { x/=10; l++; } return l; } int main() { cin>>n; for(int i=1;i<=n;i++) { a=b
2021-08-08 18:20:36
98
原创 刷题随记 洛谷P1914 小书童——凯撒密码 char爆了!!
洛谷P1914 小书童——凯撒密码. 第一次错误代码 #include<bits/stdc++.h> using namespace std; int n; char a[100]; int main() { cin>>n; n%=26; cin>>a; int len=strlen(a); for(int i=0;i<len;i++) { a[i]+=n; if(a[i]>'z') { a[i]-=26; } cout&
2021-08-08 18:14:42
432
原创 刷题随记 洛谷P5733 【深基6.例1】自动修正 大小写字母转换函数
P5733 【深基6.例1】自动修正. 垃圾代码 #include<bits/stdc++.h>## using namespace std; char a[1000]; int main() { cin>>a; int len=strlen(a); for(int i=0;i<len;i++) { if(a[i]>=97&&a[i]<=122) { a[i]-=32; } } for(int i=0;i<len
2021-08-08 18:00:36
324
原创 刷题随记 洛谷P2141 [NOIP2014 普及组] 珠心算测验 RE错误积累
洛谷P2141 [NOIP2014 普及组] 珠心算测验. RE错误积累: #include<bits/stdc++.h> using namespace std; int n,cnt=0; //int tong[10050]; //int tong2[10050]; int tong[20050]; int tong2[20050]; //20050由于最大值是10000+10000=20000, int a[150]; int main() { cin>>n; for(
2021-08-01 19:36:40
175
原创 刷题随记 洛谷P1009 [NOIP1998 普及组] 阶乘之和 高精阶乘最简洁漂亮的写法
洛谷P1009 [NOIP1998 普及组] 阶乘之和. int i,A[1005]={0},B[1005]={0},n,j; scanf("%d", &n); A[0]=B[0]=1; for (i=2;i<=n;i++){ for (j=0;j<100;j++) B[j]*=i; //先乘 for (j=0;j<100;j++) if (B[j]>9){
2021-07-29 16:07:07
123
原创 刷题随记 洛谷P1888 三角函数 __gcd 函数
洛谷P1888 三角函数. #include<iostream> #include<algorithm> using namespace std; int a[5]; int main() { cin>>a[0]>>a[1]>>a[2]; sort(a,a+3); //左闭右开 int mi=a[0],ma=a[2]; mi/=__gcd(a[0],a[2]); ma/=__gcd(a[0],a[2]); cout<<
2021-07-28 23:15:24
123
原创 ASCII码与字符的转换
利用int和char型的强制转换 ASCII码转字符 #include<iostream> using namespace std; int main() { char a; cin>>a; cout<<a<<"的ASCII码:"<<(int)a; return 0; } 字符转ASCII码 #include<iostream> using namespace std; int main() { int a; cin&g
2021-07-27 22:50:36
2354
原创 刷题随记 洛谷P2181 对角线 爆int原因
洛谷P2181 对角线. 这是一道非常有意思的思维训练题,首先看数据范围1e5则证明最多有1e5个点,若用暴力枚举边的方法(99999*99998)肯定爆时间了。我们用枚举点的办法写,从1e5中一次选取4个点,看这4个点最多能组成多少个符合要求的点。答案显示是每4个点可以组成1个符合要求的点。所以答案为Cn4 #include<iostream> using namespace std; int main() { unsigned long long n; cin>>n; u
2021-07-26 21:07:16
139
原创 刷题随记 洛谷P5705 【深基2.例7】数字反转 string翻转字符串
洛谷P5705 【深基2.例7】数字反转. 字符串基本用法一问题描述:字符串输入与翻转知识点集合:求字符串长度:翻转字符串: 问题描述:字符串输入与翻转 利用cin能输入一整行的字符串 char a[100]; cin>>a; 知识点集合: 求字符串长度: strlen(数组名) #include<cstring> char a[100]; cout<<strlen(a); 翻转字符串: reverse( 字符串名 .begin(), 字符串名 .end()
2021-07-25 16:46:17
240
原创 刷题随记 洛谷P5704 【深基2.例6】字母转换 题解 ASCII表
洛谷 P5704 【深基2.例6】字母转换. 问题描述: char型输出流语法中遇到的问题 char a=‘a’; cout<<a-32<<endl; char a=‘a’; a-=32; cout<<a<<endl; 第一种输出的结果为ASCII码值:65 第二种输出的结果为:A 原因分析: 提示:这里填写问题的分析: 例如:Handler 发送消息有两种方式,分别是 Handler.obtainMessage()和 Handler.sen
2021-07-25 15:54:10
200
原创 刷题随记 洛谷P1000 超级玛丽游戏
C++11中raw string literal技术 std::cout<<R"( ******** ************ ####....#. #..###.....##.... ###.......###### ### ### ........... .
2021-07-25 15:17:45
458
1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人