自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 浙江大学计算机与软件学院2021年考研复试上机

优化的思想是对每次遍历之前进行循环判定,只有最长的木棍max截断后短的那根记为l1,要求max/3+1

2023-03-03 17:12:20 228

原创 1080 Graduate Admission 测试点1,2

测试点1,2

2023-02-04 19:36:51 151

原创 1001 A+B Format测试点3,5,6,10,11

测试点3,5,6,10,11

2023-02-02 15:43:15 196

原创 主机访问域名的过程

访问DNS域名服务器,已知域名服务器IP地址,需要知道域名服务器的MAC地址,主机广播ARP请求分组(目的MAC为全1),域名服务器与主机在一个局域网内,域名服务器收到ARP请求分组以后,对比目的IP是自己的IP地址,就发出一个单拨ARP响应分组,携带了自己的MAC地址。主机收到响应后,以客户机的身份向本地域名服务器发送DNS请求报文,本地域名服务器先是查询有两种方法查询域名对应的IP地址,分别是递归查询和递归与迭代查询,本地域名服务器将查询结果存储在本地缓存中,并返回给主机。查询www的MAC地址。...

2022-07-30 22:34:28 4385 2

原创 1074 Reversing Linked List 测试点5、6

测试点5:每k个反转一次,不足k的不反转。错误原因:只有第一组k个反转了,而后的几组都没反转测试用例:00100 6 200000 4 9999900100 1 1230968237 6 -133218 3 0000099999 5 6823712309 2 33218输出12309 2 0010000100 1 0000000000 4 3321833218 3 6823768237 6 9999999999 5 -1测试点6:错误原因:有些节点不在头节点指

2022-02-28 11:24:57 712

原创 关键路径、最长路径

测试用例:6 80 1 30 2 20 3 22 3 51 4 33 5 22 5 34 5 1关键路径一定是有向无环图代码段#include <cstdio>#include <cstring>#include <iostream>#include <math.h>#include <stdio.h>#include <algorithm>#include <stdlib.h&gt

2022-02-27 17:43:45 1000

原创 拓扑排序 c++

#include <cstdio>#include <cstring>#include <iostream>#include <math.h>#include <stdio.h>#include <algorithm>#include <stdlib.h>#include <map>#include <vector>#include <set>#include &lt.

2022-02-27 15:57:23 525

原创 最长公共子串 字符串hash法

算法笔记P450#include <cstdio>#include <cstring>#include <iostream>#include <math.h>#include <stdio.h>#include <algorithm>#include <stdlib.h>#include <map>#include <vector>#include <set>#i

2022-02-25 23:39:46 318

原创 素数的判定

素数:只能被自己或者1整除的正整数,1不属于素数方法一:bool isPrime(int n){ if(n<=1) return false; int sqr = (int)sqrt(1.0*n); for(int i=2;i<=sqr;i++){ if(n%i==0) return false; } return true;}方法二:过筛法...

2022-02-12 20:56:32 292

原创 进制转换c++

十进制的转换int d[100];void change10ToOther(int n,int radix)//radix为目标进制{ int len =0; do{ d[len++] = n%radix; n/=radix; }while(n!=0);}//转换后的逆序存储转换为十进制int otherTo10(int n[] ,int radix){ //若输入为顺序的n int len =

2022-02-12 20:27:27 962

原创 c++中map的用法

map简单来说就是实现a到b的映射,可以自定义不同变量类型的映射头文件:#include<map>using namespace std;1. map的定义map<typename1,typename2> mp;注:字符串数组只能用string映射,不能用char数组2. map访问,与访问数组类似,直接用map[键值]访问,map中所有的键值是唯一的map<char,int> mp;mp['c'] = 20;printf("%d"

2022-02-06 22:12:54 2057

原创 1075 PAT Judge 测试点四

测试点四试了很多次是因为排序问题,把不能输出的和可以输出的记录一起排序,这里修改一下排序算法就ok了参考了知乎的文章【PAT A1075】PAT Judge(详细解决测试点4!) - 知乎 (zhihu.com)int full[10]={0};bool cmp (Student a,Student b){ if(a.total!=b.total) return a.total>b.total; else if(a.fullCount!=b.fullCount) return a.

2022-01-28 15:07:47 877

原创 c++中sort函数

头文件:#include <algorithm>using namespace std;函数://sort(数组首地址,数组尾地址+1,比较函数cmp(可省略))char a[10];sort(a,a+10,cmp);cmp比较函数伪代码bool cmp(元素A 元素B){ if(A!=B) return A>B //按元素递增次序排序}字符串比较函数strcmp#include <cstring>strcmp(char

2022-01-25 21:29:19 258

原创 一个数组复制给另一个数组 c++

#include <cstring>strcpy(目的数组, 源数组);

2022-01-25 15:07:02 2181 1

原创 输入 空格的陷阱

不可读入空格 char a[300]; scanf("%s",a);// 不能输入空格,即到输入到空格即止可以读入空格 char a; scanf("%c", a) //可以输入空格,和换行,注意不读入换行和空格时要用getchar()吸收 char a[300]; gets(temp); //可以输入空格,到换行即止 //注意 在pat中gets不兼容,要用cin.getline(a,size);.

2022-01-25 14:57:53 704

原创 int与char相互转换 c++

char -> intchar a= '1';int b= a - '0'; int -> char itoa函数(数字,字符串地址,进制)#include<iostream>#include<string>using namespace std;int main(){ int a = 123; char str[100]; itoa(a, str, 10); cout << str << e

2022-01-23 13:35:50 3151

原创 1065 A+B and C (64bit) 溢出问题

Given three integersA,BandCin( -,), you are supposed to tell whetherA+B>C.Input Specification:The first line of the input gives the positive number of test cases, T (≤10). Then T test cases follow, each consists of a single line containing ...

2022-01-15 14:51:57 111

原创 1046 Shortest Distance 超时问题

The task is really simple: givenNexits on a highway which forms a simple cycle, you are supposed to tell the shortest distance between any pair of exits.Input Specification:Each input file contains one test case. For each case, the first line conta...

2022-01-14 22:37:33 157

原创 1042 Shuffling Machine

dssdsShuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid "inside jobs" where employees collaborate with gamblers by performing inadequate shuffles, many casinos

2022-01-14 17:09:06 80

原创 1018 锤子剪刀布 scanf(“%c“,&a)的陷阱

Pat

2022-01-14 15:11:43 253

空空如也

空空如也

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

TA关注的人

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