Pat
cocohkx
这个作者很懒,什么都没留下…
展开
-
浙江大学计算机与软件学院2021年考研复试上机
优化的思想是对每次遍历之前进行循环判定,只有最长的木棍max截断后短的那根记为l1,要求max/3+1原创 2023-03-03 17:12:20 · 227 阅读 · 0 评论 -
1080 Graduate Admission 测试点1,2
测试点1,2原创 2023-02-04 19:36:51 · 150 阅读 · 0 评论 -
1001 A+B Format测试点3,5,6,10,11
测试点3,5,6,10,11原创 2023-02-02 15:43:15 · 187 阅读 · 0 评论 -
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 · 711 阅读 · 0 评论 -
拓扑排序 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 <.原创 2022-02-27 15:57:23 · 518 阅读 · 0 评论 -
最长公共子串 字符串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 · 313 阅读 · 0 评论 -
素数的判定
素数:只能被自己或者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 · 287 阅读 · 0 评论 -
进制转换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 · 956 阅读 · 0 评论 -
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 · 874 阅读 · 0 评论 -
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 · 250 阅读 · 0 评论 -
一个数组复制给另一个数组 c++
#include <cstring>strcpy(目的数组, 源数组);原创 2022-01-25 15:07:02 · 2166 阅读 · 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 · 703 阅读 · 0 评论 -
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 · 110 阅读 · 0 评论 -
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 · 152 阅读 · 0 评论 -
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 · 79 阅读 · 0 评论 -
1018 锤子剪刀布 scanf(“%c“,&a)的陷阱
Pat原创 2022-01-14 15:11:43 · 251 阅读 · 0 评论