自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(24)
  • 收藏
  • 关注

原创 【DFS习题总结】

文章目录Luogu - [P1434 [SHOI2002]滑雪](https://www.luogu.com.cn/problem/P1434)Luogu - [P1101 单词方阵](https://www.luogu.com.cn/problem/P1101)Luogu - P1434 [SHOI2002]滑雪题目描述Michael喜欢滑雪。这并不奇怪,因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道在一个区

2021-07-15 18:49:55 119

原创 【实数二分例题合集】

题目1代码#include <iostream>#include <cstring>#include <algorithm>using namespace std;int a, b, c; //贷款原值, 每月支付的分期付款金额, 还清需要的月数bool check(double mid) //利率为mid是否能还清债款{ double s = a; for (int i = 1; i <= c; i++)

2021-07-15 14:28:24 113

原创 【整数二分例题集合】

题目1(实数二分)代码#include <iostream>#include <cstring>#include <algorithm>#include <cmath>using namespace std;const double pi = acos(-1.0);const double eps = 1e-8;double r1, r2, h, v;bool check(double mid){ double R = 1

2021-07-15 11:01:44 130

原创 【分数化简】

题目lnput输入—个正整数T,表示有T组数据每组数据包括2个整数a,b分数表示a/b其中1<= T, a, b <= 100;Output请输出最简分数a/b,如果是整数就输出该整数Input:32 41 310 5Output:1/21/32代码#include <iostream>#include <cstring>#include <algorithm>using namespace std;int gcd(i

2021-07-15 10:08:40 171

原创 HDU 母牛的故事

题目思路fn代表前n年母牛的数目,先写出前几年的母牛数,试着找出规律:第n年: n=1 n=2 n=3 n=4 n=5 n=6 n=7 n=8 n=9fn头牛?f1=1 f2=2 f3=3 f4=4 f5=6 f6=9 f7=13 f8=19 f9=28我们可以得出这样一个公式:fn=fn-1+fn-3再理解一下,fn-1是前一年的牛,第n年仍然在,fn-3是前三年那一年的牛,但换句话说也就是第n年具有生育能力的牛,也就是第n年能生下的小牛数。代码#include <iostream

2021-07-15 09:52:53 59

原创 【计算多边形面积】

题目Input输入数据包含多个测试实例,每个测试实例占一行,每行的开始是一个整数n(3<=n<=100),它表示多边形的边数(当然也是顶点数),然后是按照逆时针顺序给出的n个顶点的坐标(x1, y1, x2, y2… xn, yn),为了简化问题,这里的所有坐标都用整数表示。输入数据中所有的整数都在32位整数范围内,n=0表示数据的结束,不做处理。Output对于每个测试实例,请输出对应的多边形面积,结果精确到小数点后一位小数。每个实例的输出占一行。代码多边形面积公式:S=0

2021-07-15 09:20:25 320

原创 【组合数公式】

组合数公式代码#include <iostream>#include <cstring>#include <algorithm>typedef long long LL;using namespace std;LL calc(LL n, LL m) //C(n, m):从n个数中选出m个数字 n!/(m! * (n - m)!){ LL a = 1, b = 1; for (int i = n; i >= n - m + 1;

2021-07-15 00:59:56 89

原创 Acwing 445. 数字反转

题目Acwing 445. 数字反转代码#include <iostream>#include <cstring>#include <algorithm>using namespace std;int main(){ int x; cin >> x; bool flag = false; if (x < 0) x = -x, flag = true; int ans = 0;

2021-07-15 00:33:13 72

原创 Acwing 148. 合并果子

题目Acwing 148. 合并果子前置知识STL里的优先队列 : priority_queue记得在使用之前需要 #include<queue>priority_queue默认是大根堆即堆顶元素最大,priority_queue<int> heap,完整定义:priority_queue<int, vector<int>, less<int>> heap如果定义的是小根堆:priority_queue<int, vector

2021-07-14 23:51:34 79

原创 【2~9】进制转化为10进制

八进制转化为十进制n = n * 8 + *p - ‘0’; 指针p一位一位的往后走*p-'0’就是将字符变成数字, 例如123, 当 p指向1的时候,*p = ‘1’ ,而‘1’-‘0’就是两者之间的ASCII码进行相减,结果就是1了。所以n=0*8+1=1n=1*8+2=10n=10*8+3=83n=n*2+*p-'0';//二进制转十进制P【2~9】进制转化为10进制代码以八进制数为例#include <iostream>#include <cstring&

2021-07-14 23:25:38 536

原创 CCF-202009-2 风险人群筛查

题目描述参考博文链接代码#include <iostream>#include <algorithm>#include <vector>#include <cctype>using namespace std;int n, k, t, a, b, c, d;bool inArea(int x, int y){ if (a <= x && x <= c && b <= y &&

2021-02-06 21:27:15 80

原创 CCF-202009-1-称检测点查询

题目描述链接代码#include <iostream>#include <algorithm>#include <vector>#include <cctype>using namespace std;const int N = 210;struct Point{ int s, id; bool operator< (const Point& w) const { if (s != w.s) return s &l

2021-02-06 20:50:07 70

原创 CCF-201903-2 二十四点

题目描述参考博文链接代码#include <iostream>#include <algorithm>#include <vector>#include <cctype>using namespace std;bool judge(string s){ vector<int> num; vector<char> op; for (int i = 0; i < s.size(); i++) {

2021-02-06 20:41:40 45

原创 CCF-20190301-小中大

题目描述代码#include <iostream>#include <algorithm>using namespace std;const int N = 100010;int a[N];int main(){ int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); if (n & 1) { printf("%d

2021-02-06 18:46:12 68

原创 CCF-20191202-小明种苹果(续)

题目描述代码#include <iostream>using namespace std;const int N = 1010;int apple[N];bool st[N]; //是否掉落了苹果 int n, m;int main(){ cin >> n; for (int i = 0; i < n; i++) { cin >> m >> apple[i]; for (int j = 2; j <= m

2021-02-06 18:31:10 55

原创 CCF-20190901-小明种苹果

题目描述代码#include <iostream>using namespace std;const int N = 1010;int apple[N];int cnt[N]; //疏果数目 int n, m;int main(){ cin >> n >> m; int maxCnt = -1; //最大的疏果数目 int maxId = 0; //对应的果树编号 for (int i = 1; i <= n; i

2021-02-06 18:09:18 55

原创 CCF-20191202-回收站选址

题目描述代码#include <iostream>#define x first#define y second using namespace std;typedef pair<int, int> PII;const int N = 1010;int ans[5]; //得分0~4 bool st[N]; //判断是否是设置回收站 int dx[] = {-1, 0, 1, 0}; //用来判断上下左右 int dy[] = {0, 1, 0, -

2021-02-06 16:51:17 96 1

原创 CCF-20200602-稀疏向量

题目描述注意事项对于N=10^9的维度,如果这样遍历: for (int i = 1; i <= n; i++) 去处理两个向量的乘积会超时!正确的做法应该是读取第二个向量的时候即一边处理。数据范围较大,乘积的结果可能会超过Int的范围, 需要用 long long来存储结果当数据规模N较大的时候,推荐用scanf, printf进行输入输出。代码#include <iostream>#include <cstdio>#include <vecto

2021-02-05 21:21:06 79

原创 CCF-20200601-线性分类器

题目描述代码#include <iostream>using namespace std;const int N = 1010;struct Point{ int x, y; char type; }p[N]; int c, a, b;int get(int x, int y){ return c + a * x + b * y;}int main(){// freopen("in.txt", "r", stdin); int n, m; cin

2021-02-05 20:48:23 82

原创 蓝桥杯-九数组分数

题目描述1,2,3…9 这九个数字组成一个分数,其值恰好为1/3,如何组法?下面的程序实现了该功能,请填写划线部分缺失的代码。#include <stdio.h>void test(int x[]) { int a = x[0]*1000 + x[1]*100 + x[2]*10 + x[3]; int b = x[4]*10000 + x[5]*1000 + x[6]*100 + x[7]*10 + x[8]; if(a*3 == b) printf("%d

2021-01-28 21:56:42 111

原创 蓝桥杯-格子中输出

题目描述StringInGrid函数会在一个指定大小的格子中打印指定的字符串。要求字符串在水平、垂直两个方向上都居中。如果字符串太长,就截断。如果不能恰好居中,可以稍稍偏左或者偏上一点。下面的程序实现这个逻辑,请填写划线部分缺少的代码。#include <stdio.h>#include <string.h>void StringInGrid(int width, int height, const char* s) { int i,k; char b

2021-01-28 21:48:27 209

原创 蓝桥杯-奇妙的数字

题目描述小明发现了一个奇妙的数字。它的平方和立方正好把0~9的10个数字每个用且只用了一次。你能猜出这个数字是多少吗?请填写该数字,不要填写任何多余的内容。思路本题暴力枚举+判断即可#include <iostream>#include <cstring>#include <algorithm>#include <cstdio>using namespace std;bool st[10]; //记录0~9是否存在void calc

2021-01-28 21:17:03 88

原创 蓝桥杯-方程整数解

题目描述方程: a2+b2+c2=1000a^2 + b^2 + c^2 = 1000a2+b2+c2=1000。这个方程有整数解吗?有:a,b,c=6,8,30 就是一组解。你能算出另一组合适的解吗?请填写该解中最小的数字。注意:你提交的应该是一个整数,不要填写任何多余的内容或说明性文字。思路笔者认为题目少给了一个条件即a,b,c都是正整数…本题暴力枚举即可#include <iostream>#include <cstring>#include <algo

2021-01-28 21:02:03 401

原创 蓝桥杯-星系炸弹

#include <iostream>#include <cstring>#include <algorithm>#include <cstdio>using namespace std;bool isLeap(int year){ return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);}int days[] = {0, 31, 28, 31, 30,

2021-01-28 20:47:47 125

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除