自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 选择排序(C语言)

#include<iostream>#include<algorithm>using namespace std;const int maxn=1005;int a[maxn];int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; } for(int i=1;i<n;i++){ for(int j=i

2022-01-28 11:36:35 557

原创 冒泡排序(C语言)

#include<iostream>#include<algorithm>using namespace std;const int maxn=1005;int a[maxn];int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; } for(int i=1;i<n;i++){ for(int j=i

2022-01-28 11:23:27 469

原创 堆排序(通俗易懂版)

#include<iostream>#include<algorithm>using namespace std;const int maxn=1005;int a[maxn];int len;void HeadAdjust(int a[],int k,int len){ a[0]=a[k]; for(int i=2*k;i<=len;i*=2){ if(i<len&&a[i]<a[i+1])

2022-01-28 11:17:44 131

原创 归并排序(通俗易懂版)

#include<iostream>#include<algorithm>using namespace std;const int maxn=1e5+10;int a[maxn],b[maxn];int n;void Merge(int a[],int low,int mid,int high){ int i,j,k; for(i=low;i<=high;i++) b[i]=a[i]; for(i=low,j=mid+1,k

2022-01-28 10:38:31 601

原创 PAT刷题之旅 1125-Chain the Ropes-甲级

题目Given some segments of rope, you are supposed to chain them into one rope. Each time you may only fold two segments into loops and chain them into one piece, as shown by the figure. The resulting chain will be treated as another segment of rope and can

2022-01-06 11:31:40 106

原创 PAT刷题之旅 1122-Hamiltonian Cycle-甲级

题目The “Hamilton cycle problem” is to find a simple cycle that contains every vertex in a graph. Such a cycle is called a “Hamiltonian cycle”.In this problem, you are supposed to tell if a given cycle is a Hamiltonian cycle.Input Specification:Each inpu

2022-01-06 11:09:30 408

原创 PAT刷题之旅 1121-Damn Single-甲级

题目“Damn Single (单身狗)” is the Chinese nickname for someone who is being single. You are supposed to find those who are alone in a big party, so they can be taken care of.Input Specification:Each input file contains one test case. For each case, the first

2022-01-05 18:27:32 440

原创 PAT刷题之旅 1113-Integer Set Partition-甲级

题目Given a set of N (> 1) positive integers, you are supposed to partition them into two disjoint sets A1 and A2 of n1 and n2 numbers, respectively. Let S1 and S2 denote the sums of all the numbers in A1 and A2, respectively. You are supposed to make th

2022-01-05 16:59:19 277

原创 PAT刷题之旅 1144-The Missing Number-甲级

题目Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list.Input Specification:Each input file contains one test case. For each case, the first line gives a positive integer N (<= 105). Then N integers ar

2022-01-04 11:47:31 251

原创 PAT刷题之旅 1151-LCA in a Binary Tree-甲级

题目The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.Given any two nodes in a binary tree, you are supposed to find their LCA.Input Specification:Each input file contains one test ca

2022-01-03 17:12:24 416

原创 PAT刷题之旅 1149-Dangerous Goods Packaging-甲级

题目When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we might get ourselves in serious trouble. For example, oxidizing agent (氧化剂) must not be packed with flammable liquid (易燃液体), or

2022-01-03 16:13:13 68

原创 PAT刷题之旅 1148-Werewolf - Simple Version-甲级

题目Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose that in a game,player #1 said: “Player #2 is a werewolf.”;player #2 said: “Player #3 is a human.”;player #3 said: “Player #4 i

2022-01-03 10:52:58 9704

原创 pat甲级题型记录

1001 栈思想的应用1003 dijkstra算法最短路变式1005 数字转字符串以及字符串转数字1007 最大连续子序列

2021-12-13 19:39:44 159

原创 活用递推算法(待更新)

hhhh

2021-11-10 10:15:07 211

原创 算法学习杂记

最短路问题贪心问题活用递推pat A1093

2021-11-10 10:13:51 57

原创 algorithm——并查集

目录一:并查集解释二:例题一:并查集解释转的一个超级有意思,好懂的并查集解释。原链接在此 点此处故事读完,并查集就会了~~~~~江湖上散落着各式各样的大侠,有上千个之多。他们没有什么正当职业,整天背着剑在外面走来走去,碰到和自己不是一路人的,就免不了要打一架。但大侠们有一个优点就是讲义气,绝对不打自己的朋友。而且他们信奉“朋友的朋友就是我的朋友”,只要是能通过朋友关系串联起来的,不管拐了多少个弯,都认为是自己人。这样一来,江湖上就形成了一个一个的帮派,通过两两之间的朋友关系串联起来。

2020-08-26 10:24:38 151

原创 algorithm——一些有趣的思维题

HDU 1108#include"iostream"using namespace std;int main(){ int a,b,c[4],t,cnt; while(cin>>a>>b) { t=a%10; c[1]=t; c[2]=t*c[1]%10; c[3]=t*c[2]%10; c[0]=t*c[3]%10; cnt=c[b%4];

2020-08-26 09:55:29 120

原创 algorithm——动态规划

HDU2044#include"iostream"using namespace std;const int maxn=110;long long dp[maxn];int main(){ int t,a,b; cin>>t; while(t--) { cin>>a>>b; dp[0]=1; dp[1]=1; for(int i=2;i<=b;i++)

2020-08-26 09:52:59 180

原创 排序算法总结

![[外链图片转存中…(img-LU1L1y2f-1594221651552)](一)选择排序(1)选择排序

2020-07-19 10:28:12 301

原创 Datawhale task2

XpathXPath是XML的路径语言,通俗一点讲就是通过元素的路径来查找到这个标签元素。Xpath使用方法1、Xpath支持ID、Class、Name定位功能1)、通过ID定位     //[@id=‘kw’]   2)、通过Class定位    //[@class=‘class_name’]  3)、通过Name定位   //*[@name=‘name’]xpath语法...

2020-04-23 23:21:21 106

原创 Datewhale爬虫学习活动打卡--task1

HTMLHTML (HyperText Markup Language) 不是一门编程语言,而是一种用来告知浏览器如何组织页面的标记语言。HTML 可复杂、可简单,一切取决于开发者。它由一系列的元素(elements)组成,这些元素可以用来包围不同部分的内容,使其以某种方式呈现或者工作。 一对标签( tags)可以为一段文字或者一张图片添加超链接,将文字设置为斜体,改变字号,等等。Requst...

2020-04-21 15:46:59 159

原创 ctype.h头文件详解

<ctype.h> 是一个与字符处理有关的头文件,它包含了一系列用于检测和转换单个字符的函数。<ctype.h> 中的函数都只有一个参数,就是要检测或者要转换的字符,并且这个参数的类型是 int,它可以表示一个有效字符,或者一个EOF(无效字符)。<ctype.h> 中的函数的返回值也都是 int 类型,它可以表示一个有效字符,或者一个EOF(无效字符),或...

2020-04-20 12:07:35 2323

原创 HDU 2099 整除的尾数

Problem Description 一个整数,只知道前几位,不知道末二位,被另一个整数除尽了,那么该数的末二位该是什么呢?Input 输入数据有若干组,每组数据包含二个整数a,b(0<a<10000, 10<b<100),若遇到0 0则处理结束。Output 对应每组数据,将满足条件的所有尾数在一行内输出,格式见样本输出。同组数据的输出,其每个尾数之间空一格,行末没...

2020-04-20 12:06:17 117

原创 HDU 4548 美素数

Problem Description   小明对数的研究比较热爱,一谈到数,脑子里就涌现出好多数的问题,今天,小明想考考你对素数的认识。  问题是这样的:一个十进制数,如果是素数,而且它的各位数字和也是素数,则称之为“美素数”,如29,本身是素数,而且2+9 = 11也是素数,所以它是美素数。  给定一个区间,你能计算出这个区间内有多少个美素数吗?Input 第一行输入一个正整数T,表示总...

2020-04-20 11:18:46 333

原创 常见算法

/*//素数的判定 #include"stdio.h"#include"math.h"int main(){ int a, k, i; while (~scanf("%d",&a)) { k = (int)sqrt((double)a); for (i = 2;i<=k;i++){ if(a%i==0) break; } if(i>k)...

2020-04-15 00:41:46 101

原创 HDU 2503 a/b + c/d

Problem Description 给你2个分数,求他们的和,并要求和为最简形式。Input 输入首先包含一个正整数T(T<=1000),表示有T组测试数据,然后是T行数据,每行包含四个正整数a,b,c,d(0<a,b,c,d<1000),表示两个分数a/b 和 c/d。Output 对于每组测试数据,输出两个整数e和f,表示a/b + c/d的最简化结果是e/f,每组输...

2020-04-15 00:39:09 174

原创 HDU 2519 新生晚会

Problem Description 开学了,杭电又迎来了好多新生。ACMer想为新生准备一个节目。来报名要表演节目的人很多,多达N个,但是只需要从这N个人中选M个就够了,一共有多少种选择方法?Input 数据的第一行包括一个正整数T,接下来有T组数据,每组数据占一行。每组数据包含两个整数N(来报名的人数,1<=N<=30),M(节目需要的人数0<=M<=30)Ou...

2020-04-15 00:35:36 136

原创 HDU 2025 查找最大元素

Problem Description 对于输入的每个字符串,查找其中的最大字母,在该字母后面插入字符串“(max)”。Input 输入数据包括多个测试实例,每个实例由一行长度不超过100的字符串组成,字符串仅由大小写字母构成。Output 对于每个测试实例输出一行字符串,输出的结果是插入字符串“(max)”后的结果,如果存在多个最大的字母,就在每一个最大字母后面都插入"(max)"。Sam...

2020-04-15 00:27:40 103

原创 HDU 2084 数塔

Problem Description 在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的:有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少?已经告诉你了,这是个DP的题目,你能AC吗?Input 输入数据首先包括一个整数C,表示测试实例的个数,每个测试实例的第一行是一个整数N(1 <= N <= 100),表示数塔...

2020-04-15 00:25:43 120

原创 HDU 2043 密码

Problem Description网上流传一句话:“常在网上飘啊,哪能不挨刀啊~”。其实要想能安安心心地上网其实也不难,学点安全知识就可以。首先,我们就要设置一个安全的密码。那什么样的密码才叫安全的呢?一般来说一个比较安全的密码至少应该满足下面两个条件:(1).密码长度大于等于8,且不要超过16。(2).密码中的字符应该来自下面“字符类别”中四组中的至少三组。这四个字符类别分别为:...

2020-04-15 00:20:29 245

原创 HDU 2041 超级楼梯

Problem Description 有一楼梯共M级,刚开始时你在第一级,若每次只能跨上一级或二级,要走上第M级,共有多少种走法?Input 输入数据首先包含一个整数N,表示测试实例的个数,然后是N行数据,每行包含一个整数M(1<=M<=40),表示楼梯的级数。Output 对于每个测试实例,请输出不同走法的数量Sample Input223Sample Output...

2020-04-14 23:56:52 275

原创 HDU 2032 杨辉三角

Problem Description 还记得中学时候学过的杨辉三角吗?具体的定义这里不再描述,你可以参考以下的图形:11 11 2 11 3 3 11 4 6 4 11 5 10 10 5 1Input 输入数据包含多个测试实例,每个测试实例的输入只包含一个正整数n(1<=n<=30),表示将要输出的杨辉三角的层数。Output 对应于每一个输入,请输出相应层数的杨辉...

2020-04-14 23:53:43 145

原创 统计指定字符个数

B.CQW的倔强LCH和LPF是大学,每天都在讨论一些很高深的问题,像迪利克雷卷积之类的简单东西,他们根本不屑一顾。CQW是出了名的学渣,可是学渣也是有上进心的呀,他相信天道酬勤,只要他肯努力,一定可以赶上LCH和LPF的。有道是,一定要努力,只有努力过后,才能明白自己真的是不行。CQW在一次LCH和LPF讨论完后,趁着他们出去的功夫,他偷到了他们使用的手稿!CQW如获至宝,马上就开始研究他们讨...

2020-04-14 23:50:27 516

原创 字符串左移(右移)

A.CQW又迟到了CQW是个坏学生,每天都迟到,从没看见他在第一节课出现过,懒惰的他,总是在点名的最后一刻出现。为了治一治他这个坏习惯,教C语言的XZW老师决定每天都给他布置一个单独的作业,并答应只要他每次都能正确完成作业就不点他的名字,CQW为了可以多睡觉,立刻答应了下来。为了让CQW知难而退,于是第一天XZW老师就布置了一个超级难的题!将一个字符串循环打印输出成一个 n * n 的矩阵。...

2020-04-14 23:45:56 1755

原创 HDU 1228 A + B

Problem Description读入两个小于100的正整数A和B,计算A+B.需要注意的是:A和B的每一位数字由对应的英文单词给出.Input测试输入包含若干测试用例,每个测试用例占一行,格式为"A + B =",相邻两字符串有一个空格间隔.当A和B同时为0时输入结束,相应的结果不要输出.Output对每个测试用例输出1行,即A+B的值.Sample Inputone + t...

2020-04-14 19:00:44 96

原创 杭电 oj 1019 Least Common Multiple

Problem Description The least common multiple (LCM) of a set of positive integers is the smallest positive integer which is divisible by all the numbers in the set. For example, the LCM of 5, 7 and 15...

2020-04-02 18:26:50 191

原创 杭电 oj 1076 An Easy Task C++

Problem Description Ignatius was born in a leap year, so he want to know when he could hold his birthday party. Can you tell him?Given a positive integers Y which indicate the start year, and a posit...

2020-03-26 10:36:10 124

原创 杭电 oj 1097 A hard puzzle C++

Problem Description lcy gives a hard puzzle to feng5166,lwg,JGShining and Ignatius: gave a and b,how to know the a^b.everybody objects to this BT problem,so lcy makes the problem easier than begin.t...

2020-03-25 22:15:09 136

原创 杭电 oj 2010 水仙花数 C++

Problem Description 春天是鲜花的季节,水仙花就是其中最迷人的代表,数学上有个水仙花数,他是这样定义的:“水仙花数”是指一个三位数,它的各位数字的立方和等于其本身,比如:153=13+53+3^3。现在要求输出所有在m和n范围内的水仙花数。Input 输入数据有多组,每组占一行,包括两个整数m和n(100<=m<=n<=999)。Output 对于每个测...

2020-03-15 01:00:57 203

原创 C语言倒序输出的方法(普通输出和指针输出)

c语言倒序输出的方法常用的为两种。方法一:指针输出#include<stdio.h>int main(){ int a[100],*p, temp, n; p=a; scanf("%d",&n); for(int i = 0;i < n;i++) scanf("%d",p+i); for(int i = 0;i <= n/2;i++) { ...

2020-03-12 11:43:49 3887 2

空空如也

空空如也

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

TA关注的人

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