自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 SQL作业

啧啧

2022-11-24 23:57:01 122 1

原创 最短路算法总结

最短路算法由浅入深

2022-08-13 14:47:17 106

原创 背包模板(内存空间最简版)

完全背包:多重背包(小数据范围):多重背包(较大数据范围):多重背包(特大数据范围):(无脑记模板吧 好像和单调队列有关)分组背包:混合背包视情况而定: if(符合01背包)用01背包; if(符合完全背包)就用完全背包 ......

2022-06-16 12:22:17 177

原创 开课吧 封装-构造和析构

构造和析构如果自己没有写构造函数,编译器会自动生成一个无参构造函数普通构造函数拷贝构造函数,和无参构造函数一样,自己不写,编译器会自动生成一个析构函数,编译器也会自动生成一个,但一般需要自己手写一个来完成释放堆空间的功能构造函数和析构函数放在public权限下构造函数的一般写法:People(string _name, int _age, double _weight, double _height) : name(_name), age(_age), weight

2022-04-14 15:06:56 437

原创 开课吧 封装-类和对象

类内属性占据字节问题:People p; 这种定义方式存放在栈区,计算机自动释放内存People* p=new(); 这种定义方式存放在堆区,程序员手动释放类的成员属性占多少大小的内存,类对象就占多少大小的内存(有特殊情况)如果类内定义了虚函数,则类内存会多八个字节(虚函数表)类内的成员方法对类内存无影响。类存储时的内存对齐问题:#include<iostream>using namespace std;class People { int age; /.

2022-04-10 14:27:48 178

原创 搜索(DFS BFS)

深搜一般用递归实现,广搜一般用队列实现 本质仍然是暴力枚举,只是枚举方式不同连通性问题适合用深搜来解决,最短路适合用广搜来解决搜索注意事项:存地图,如果从(1,1)开始存图,一般不用判断边界 方向数组 int dir[4][2]={1,0,-1,0,0,1,0,-1}; 去重 包括改地图和mark[]标记数组两种方法相关题目:题目描述(小明吃饭)​ 难得的休息日,小明起床时就已经 11 点多了,他常去的馅饼店一般 12 点就没饭了,他需要赶紧洗漱,出门,然后去馅饼店吃饭,到了小区.

2022-03-30 17:21:48 142

原创 递归于排列组合问题

题目描述(递归实现指数型枚举)​ 从 1−n这 n 个整数中随机选取任意多个,每种方案里的数从小到大排列,按字典序输出所有可能的选择方案。输入​ 输入一个整数 n。(1≤n≤10)输出​ 每行一组方案,每组方案中两个数之间用空格分隔。​ 注意每行最后一个数后没有空格。样例输入:3样例输出:11 21 2 31 322 33AC代码:#include<iostream>using namespace std;//递归,...

2022-03-30 13:54:16 214

原创 蓝桥杯 星系炸弹

#include<iostream>#include<cstdio>#define ll long#include<cmath>#include<cstring>#include<string>using namespace std;int a, b, c, n;int days[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };bool func(int x) { return .

2022-02-07 11:07:29 6421

原创 基于栈和二叉树实现广义表转二叉树

#include<stdio.h>#include<stdlib.h>#include<string.h>#include<iostream>using namespace std;//二叉树的结构定义typedef struct Node { char data; struct Node* lchild, * rchild;}Node;typedef struct tree { Node* root; int length;}Tr.

2022-02-06 16:05:03 210

原创 二叉搜索树代码实现

//令人头大的 ·二叉搜索树·#include<stdio.h>#include<stdlib.h>#include<time.h>typedef struct Node { int val,size;//size代表当前节点下面有几个节点 struct Node* left, * right;}Node; //开课吧平衡二叉树上有具体讲解NILNode __NIL;#define NIL (&__NIL)#define INITIA.

2022-02-06 16:01:48 230 1

原创 二叉树的代码实现

#include<stdio.h>#include<stdlib.h>#include<time.h>typedef struct Node { int data; struct Node* lchild, * rchild;}Node;typedef struct Tree { Node* root; int length;}Tree;Node* get_newNode(int val) { Node* p = (Node*)malloc(si.

2022-02-06 16:00:28 704

原创 栈的代码实现

#include<stdlib.h>#include<stdio.h>#include<time.h>#define COLOR(a,b) "\033[" #b "m" a "\033[0m"#define GREEN(a) COLOR(a,32)#define RED(a) COLOR(a,31)typedef struct Stack { int *data; int top, size;};Stack* init(int n) { Stack.

2022-02-06 15:58:49 78

原创 队列的代码实现(两种方式)

#include<stdio.h>#include<stdlib.h>#include<time.h>#define COLOR(a,b) "\033[" #b "m" a "\033[0m"#define GREEN(a) COLOR(a,32)#define RED(a) COLOR(a,31)typedef struct Queue { int* data; int head, tail, length; int count;};Queue*.

2022-02-06 15:57:44 993

原创 顺序表的实现

#include<stdio.h>#include<stdlib.h>#include<time.h>#define COLOR(a, b) "\033[" #b "m" a "\033[0m"#define GREEN(a) COLOR(a,32) #define RED(a) COLOR(a,31)//定义typedef struct Vector { int *data; int size, length;}Vec;//初始化Vec* in.

2022-02-06 15:54:51 164

原创 链表代码演示

#include<stdio.h>#include<time.h>#include<stdlib.h>#define COLOR(a,b) "\033[" #b "m" a "\033[0m"#define GREEN(a) COLOR(a,32)typedef struct Node { int data; struct Node* next;}Node;typedef struct List { Node head; //如果不用指针变量来存储,.

2022-02-06 15:52:43 284

原创 图论算法 待补充

1. 贝尔福特曼#include<iostream>using namespace std;#include<cstring>#include<cstdio>struct edge { int s, e, v; //起点,终点,边权};edge edg[200005]; //存储两次int n, m, s, ans[100005], cnt;void add_edge(int a, int b, int c) { edg[cnt].s = a;

2022-02-06 15:49:47 139

原创 小tips

一、二进制枚举1:____builtin_popcount(i)函数的作用是求出i对应的二进制表达式中有几个12:当用visual studio编译的时候,需要加上这两行代码,该函数才能正常使用,在网上正式提交答案的时候,需要自行再把这两行删了。#define __builtin_popcount __popcnt #define __builtin_popcountl __popcnt3:对应题目链接:洛谷1036题4:完整代码如下:#include<iostream&

2022-01-16 15:30:08 268

原创 WERTYU UVa10082

题意:把手放在键盘上时,稍不注意就会往右错一 位。这样,输入Q会变成输入W,输入J会变成输 入K等。键盘如图3-2所示。输入一个错位后敲出的字符串(所有字母均 大写),输出打字员本来想打出的句子。输入保 证合法,即一定是错位之后的字符串。例如输入中不会出现大写字母A。样例输入:O S, GOMR YPFSU/样例输出:I AM FINE TODAY.AC代码:#include<iostream>using namespace std;char .

2021-12-14 16:44:37 93

原创 Tex Quotes UVa 272

题意:输入m个长度为n的DNA序列,求一个DNA序列,到所有序列的总Hamming距离尽量小。两个等长度的Hamming距离等于字符不同的位置个数,例如:ACGT和GCGA都Hamming距离为2(左边第一和第四个字符不同)输入整数m和n(4<=m<=50, 4<=n<=1000),...

2021-12-14 16:37:46 1052

原创 蓝桥杯 直线 map与vector的简单应用

试题 C: 直线10 分在平面直角坐标系中,两点可以确定一条直线。如果有多点在一条直线上,那么这些点中任意两点确定的直线是同一条。给定平面上2 × 3个整点{(x, y)|0 ≤ x < 2, 0 ≤ y < 3, x ∈ Z, y ∈ Z},即横坐标是0到 1 (包含 0 和 1) 之间的整数、纵坐标是 0 到 2 (包含0和 2) 之间的整数的点。这些点一共确定了 11 条不同的直线。给定平面上 20× 21 个整点{(x, y)|0 ≤ x < 20, 0 ≤ y &

2021-12-08 14:30:37 4154

原创 The Luckiest number(二分快速幂+欧拉函数)

DescriptionChinese people think of '8' as the lucky digit. Bob also likes digit '8'. Moreover, Bob has his own lucky numberL. Now he wants to construct his luckiest number which is the minimum among all positive integers that are a multiple ofLand con...

2021-12-06 12:56:55 96

原创 最大乘积 (全排列)

题目描述Description把1~9这9个数字分成两组,中间插入乘号,有的时候,它们的乘积也只包含1~9这9个数字,而且每个数字只出现1次。比如:984672*351=34561987298751*3462=3418759629*87146325=784316925...符合这种规律的算式还有很多,请你计算在所有这些算式中,乘积最大是多少?注意,需要提交的是一个整数,表示那个最大的积,不要填写任何多余的内容。(只提交乘积,不要提交整个...

2021-11-27 10:48:16 644

原创 等差素数列(素数筛+暴力枚举)

题目描述Description2,3,5,7,11,13,....是素数序列。类似:7,37,67,97,127,157这样完全由素数组成的等差数列,叫等差素数数列。上边的数列公差为30,长度为6。2004年,格林与华人陶哲轩合作证明了:存在任意长度的素数等差数列。这是数论领域一项惊人的成果!有这一理论为基础,请你借助手中的计算机,满怀信心地搜索:长度为10的等差素数列,其公差最小值是多少?注意:需要提交的是一个整数,不要填写任何多余的内容和说明文字。答案:210.

2021-11-26 14:42:37 197

原创 Longge‘s problem(欧拉函数的应用+因式枚举)

DescriptionLongge is good at mathematics and he likes to think about hard mathematical problems which will be solved by some graceful algorithms. Now a problem comes: Given an integer N(1 < N < 2^31),you are to calculate ∑gcd(i, N) 1<=i <=N.

2021-11-22 13:33:02 244

原创 Become A Hero(欧拉函数预选筛+素数筛)

Problem DescriptionLemon wants to be a hero since he was a child. Recently he is reading a book called “Where Is Hero From” written by ZTY. After reading the book, Lemon sends a letter to ZTY. Soon he recieves a reply.Dear Lemon,It is my way of success

2021-11-21 11:00:55 194

原创 Problem D. Euler Function(欧拉函数的性质)

Problem DescriptionIn number theory, Euler's totient functionφ(n)counts the positive integers up to a given integernthat are relatively prime ton. It can be defined more formally as the number of integerskin the range1≤k≤nfor which the greatest ...

2021-11-21 10:20:07 334

原创 Find the maximum(素数筛+高精度乘法+二分+欧拉函数性质分析)

Problem DescriptionEuler's Totient function, φ (n) [sometimes called the phi function], is used to determine the number of numbers less than n which are relatively prime to n . For example, as 1, 2, 4, 5, 7, and 8, are all less than nine and relatively p

2021-11-20 16:52:44 246

原创 The Euler function(欧拉函数预处理+素数筛+一维数组求前缀和)

DescriptionThe Farey Sequence Fn for any integer n with n >= 2 is the set of irreducible rational numbers a/b with 0 < a < b <= n and gcd(a,b) = 1 arranged in increasing order. The first few areF2 = {1/2}F3 = {1/3, 1/2, 2/3}F4 = {1/4, 1/3,

2021-11-19 13:55:55 264

原创 The Euler function(欧拉函数预处理+素数筛+一维数组前缀和)

Problem DescriptionThe Euler function phi is an important kind of function in number theory, (n) represents the amount of the numbers which are smaller than n and coprime to n, and this function has a lot of beautiful characteristics. Here comes a very e

2021-11-18 15:20:02 284

原创 GCD Again

Problem DescriptionDo you have spent some time to think and try to solve those unsolved problem after one ACM contest?No? Oh, you must do this when you want to become a "Big Cattle".Now you will find that this problem is so familiar:The greatest commo

2021-11-18 14:55:05 43

原创 找新朋友(欧拉函数+素数筛预选处理)

Problem Description新年快到了,“猪头帮协会”准备搞一个聚会,已经知道现有会员N人,把会员从1到N编号,其中会长的号码是N号,凡是和会长是老朋友的,那么该会员的号码肯定和N有大于1的公约数,否则都是新朋友,现在会长想知道究竟有几个新朋友?请你编程序帮会长计算出来。Input第一行是测试数据的组数CN(Case number,1<CN<10000),接着有CN行正整数N(1<n<32768),表示会员人数。Output对于每一个N,

2021-11-18 14:41:46 182 2

原创 Relatives(素数筛+欧拉函数)

DescriptionGiven n, a positive integer, how many positive integers less than n are relatively prime to n? Two integers a and b are relatively prime if there are no integers x > 1, y > 0, z > 0 such that a = xy and b = xz.InputThere are sever

2021-11-18 14:18:27 164

原创 小明系列故事——师兄帮帮忙

Problem Description  小明自从告别了ACM/ICPC之后,就开始潜心研究数学问题了,一则可以为接下来的考研做准备,再者可以借此机会帮助一些同学,尤其是漂亮的师妹。这不,班里唯一的女生又拿一道数学题来请教小明,小明当然很高兴的就接受了。不过等他仔细读题以后,发现自己也不会做,这下小明囧了:如果回复说自己不懂,岂不是很没面子?  所以,他现在私下求你帮忙解决这道题目,题目是这样的:  给你n个数字,分别是a1,a2,a3,a4,a5……an,这些数字每过一个单位时间就会改变,假设上一

2021-11-17 21:31:57 107

原创 Pupu(二分快速幂)

Problem DescriptionThere is an island called PiLiPaLa.In the island there is a wild animal living in it, and you can call them PuPu. PuPu is a kind of special animal, infant PuPus play under the sunshine, and adult PuPus hunt near the seaside. They fell

2021-11-17 18:54:33 172

原创 Pseudoprime numbers

DescriptionFermat's theorem states that for any prime numberpand for any integera> 1,ap=a(modp). That is, if we raiseato thepthpower and divide byp, the remainder isa. Some (but not very many) non-prime values ofp, known as base-apseu...

2021-11-17 10:17:50 450

原创 Raising Modulo Numbers

DescriptionPeople are different. Some secretly read magazines full of interesting girls' pictures, others create an A-bomb in their cellar, others like using Windows, and some like difficult mathematical games. Latest marketing research shows, that this

2021-11-16 22:23:49 91

原创 P1226 【模板】快速幂||取余运算

题目描述给你三个整数a,b,pa,b,p,求a^b \bmod pabmodp。输入格式输入只有一行三个整数,分别代表a,b,pa,b,p。输出格式输出一行一个字符串a^b mod p=s,其中a,b,pa,b,p分别为题目给定的值,ss为运算结果。输入输出样例输入 #12 10 9输出 #12^10 mod 9=7说明/提示样例解释2^{10} = 1024210=1024,1024 \bmod 9 = 71024mod9=7。...

2021-11-16 22:03:23 534

原创 Rightmost Digit(循环节快速幂)

Problem DescriptionGiven a positive integer N, you should output the most right digit of N^N.InputThe input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow.Eac

2021-11-16 21:58:35 191

原创 人见人爱A^B

Problem Description求A^B的最后三位数表示的整数。 说明:A^B的含义是“A的B次方”Input输入数据包含多个测试实例,每个实例占一行,由两个正整数A和B组成(1<=A,B<=10000),如果A=0, B=0,则表示输入数据的结束,不做处理。Output对于每个测试实例,请输出A^B的最后三位表示的整数,每个输出占一行。Sample Input2 3 12 6 6789 10000 0 0Sample Output8 984 1

2021-11-16 21:49:47 49

空空如也

空空如也

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

TA关注的人

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