![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
kikook
这个作者很懒,什么都没留下…
展开
-
2020湖南大学ACM新生杯题解- A Counting 0 and 1 in string
这是今天的第一题,人生中第一次参加ACM赛制的比赛,整整5小时,不喝水吃饭上厕所,就不停的写代码,在TLE,WA,Compile Error中凌乱。新生杯,顾名思义,是给新生参加的,我已然是大四的老人了,但是依然选了这门不水的课程(相较于其他课程),一道算法题(RSA这种)接连研究个两天也是有的,今天也参加了这门课程测试——暨 2020 HNU ACM 新生杯。为什么这个题,我要记上一笔?因为这个伪装成字符串的斐波那契数列消耗了我整整一个多小时,开始看题,一看题目String就觉得是模拟题,这两..原创 2020-12-27 00:21:47 · 808 阅读 · 0 评论 -
2020湖南大学ACM新生杯题解- D Treasure Cave
思路:将地上的所有数和空中的数放在一起排序,空中的拿出意思就是可以最终从这个排好序的序列中抽出任意一个数,使得剩下的序列为严格的上升序列。并且题目希望尽可能大,检查这个排好序的序列,如果这个序列中有两个连续相同的数就拿出其中一个,如果出现两组以上的相同的数,例如样例中的 3 4 1 4 4 排序后的序列为 1 4 4 4,有两组,就无法构成,输出0,这个题差一丢丢就对了,可惜了。#define _CRT_SECURE_NO_WARNINGS#include <cstdio&g..原创 2020-12-26 22:58:05 · 719 阅读 · 0 评论 -
[HOJ 10178] 最大公约数 (Greatest Common Divisor)
最大公约数 Time Limit:1000ms,Special Time Limit:2500ms,Memory Limit:32768KB Total submit users:2211,Accepted users:1898 Problem 10178 :No special judgement Problem description 输入两个整数a,b(1≤a,b≤100000000),请编写程序求出他们的最大公约数。 Input 第一个数n表示测试...原创 2020-12-23 18:58:00 · 650 阅读 · 0 评论 -
[HOJ 10182] 置换排列
置换排列 Time Limit:1000ms,Special Time Limit:2500ms,Memory Limit:32768KB Total submit users:1290,Accepted users:1137 Problem 10182 :No special judgement Problem description 给定一个自然数n 和 1到n的一个排列,比如 4 及 排列 1 4 3 2,我们说1放在第1个位置,第1个位置放了1,4放在第2个位置,第...原创 2020-12-23 01:55:03 · 311 阅读 · 0 评论 -
[HOJ 10146] Number lengths
Numberlengths Time Limit:1000ms,Special Time Limit:2500ms,Memory Limit:32768KB Total submit users:1509,Accepted users:1405 Problem 10146 :No special judgement Problem description N! (N factorial) can be quite irritating and difficult to c...原创 2020-12-23 00:22:48 · 250 阅读 · 0 评论 -
[HOJ 10144] Base 9 Calculator
Base9Calculator Time Limit:1000ms,Special Time Limit:2500ms,Memory Limit:32768KB Total submit users:1035,Accepted users:898 Problem 10144 :No special judgement Problem description Normally, you use base 10 to do arithmetic. In computer s...原创 2020-12-22 22:34:40 · 508 阅读 · 0 评论 -
[HOJ 10136] Palindromes
Palindromes Time Limit:1000ms,Special Time Limit:2500ms,Memory Limit:32768KB Total submit users:1853,Accepted users:1481 Problem 10136 :No special judgement Problem description Background: Palindromes are strings that read the same both...原创 2020-12-22 20:51:00 · 356 阅读 · 0 评论 -
[洛谷 P1177] 【模板】快速排序
题目描述利用快速排序算法将读入的NN个数从小到大排序后输出。快速排序是信息学竞赛的必备算法之一。对于快速排序不是很了解的同学可以自行上网查询相关资料,掌握后独立完成。(C++C++选手请不要试图使用STL,虽然你可以使用sort一遍过,但是你并没有掌握快速排序算法的精髓。)输入格式第11行为一个正整数NN,第22行包含NN个空格隔开的正整数a_iai,为你需要进行排序的数,数据保证了A_iAi不超过10^9109。输出格式将给定的NN个数从小...原创 2020-12-22 15:57:56 · 520 阅读 · 0 评论 -
[HNU 10072] Fibonacci Number
FibonacciNumber Time Limit:1000ms,Special Time Limit:2500ms,Memory Limit:32768KB Total submit users:2105,Accepted users:1749 Problem 10072 :No special judgement Problem description The Fibonacci Numbers {0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 5...原创 2020-12-21 01:15:32 · 342 阅读 · 0 评论 -
[HNU 10054] 拦截导弹
拦截导弹 Time Limit:1000ms,Special Time Limit:2500ms,Memory Limit:32768KB Total submit users:1177,Accepted users:599 Problem 10054 :No special judgement Problem description 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统。但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹...原创 2020-12-21 00:32:40 · 320 阅读 · 0 评论 -
[HNU 10047] Adding Reversed Numbers
AddingReversedNumbers Time Limit:1000ms,Special Time Limit:2500ms,Memory Limit:32768KB Total submit users:1003,Accepted users:586 Problem 10047 :No special judgement Problem description The Antique Comedians of Malidinesia prefer comedie...原创 2020-12-20 15:16:53 · 237 阅读 · 0 评论 -
[HNU 10042] SpinLock
SpinLock Time Limit:1000ms,Special Time Limit:2500ms,Memory Limit:32768KB Total submit users:1142,Accepted users:874 Problem 10042 :No special judgement Problem description Simulate a locked spinner puzzle. A locked spinner puzzle ...原创 2020-12-19 23:42:33 · 355 阅读 · 1 评论 -
[HNU 10058] Server
Server Time Limit:1000ms,Special Time Limit:2500ms,Memory Limit:32768KB Total submit users:1391,Accepted users:1295 Problem 10058 :No special judgement Problem description Users of computers frequently enter URLs (Uniform Resource Loca...原创 2020-12-19 22:49:37 · 363 阅读 · 1 评论 -
[HNU 10052] Sum
Sum Time Limit:1000ms,Special Time Limit:2500ms,Memory Limit:32768KB Total submit users:1451,Accepted users:1296 Problem 10052 :No special judgement Problem description Consider the natural numbers from 1 to N. By associating to each numbe...原创 2020-12-19 22:11:05 · 247 阅读 · 1 评论 -
[HNU 10051] Perfection
Perfection Time Limit:1000ms,Special Time Limit:2500ms,Memory Limit:32768KB Total submit users:1351,Accepted users:1130 Problem 10051 :No special judgement Problem description From the article Number Theory in the 1994 Microsoft Encarta: `...原创 2020-12-17 22:05:02 · 256 阅读 · 0 评论 -
[HNU 10049] IP Address
IPAddress Time Limit:1000ms,Special Time Limit:2500ms,Memory Limit:32768KB Total submit users:2341,Accepted users:2194 Problem 10049 :No special judgement Problem description Suppose you are reading byte streams from any device, represent...原创 2020-12-17 18:51:30 · 188 阅读 · 0 评论 -
[HNU 10013] Calendar
Calendar Time Limit:1000ms,Special Time Limit:2500ms,Memory Limit:32768KB Total submit users:1771,Accepted users:1504 Problem 10013 :No special judgement Problem description A calendar is a system for measuring time, from hours and minutes...原创 2020-12-17 11:43:33 · 230 阅读 · 0 评论 -
[HNUOJ 10014] The Triangle
TheTriangle Time Limit:1000ms,Special Time Limit:2000ms,Memory Limit:32768KB Total submit users:2021,Accepted users:1503 Problem 10014 :No special judgement Problem description 73 88 1 02 7 4 44 5 2 6...原创 2020-12-16 23:54:14 · 247 阅读 · 0 评论 -
[HNU 10050] Jolly Jumpers
JollyJumpers Time Limit:1000ms,Special Time Limit:2500ms,Memory Limit:32768KB Total submit users:2174,Accepted users:1945 Problem 10050 :No special judgement Problem description A sequence of n > 0 integers is called a jolly jumper if ...原创 2020-12-16 20:48:57 · 256 阅读 · 0 评论 -
[HNUOJ 10045] Joseph‘s Puzzle
Joseph'sPuzzle Time Limit:1000ms,Special Time Limit:2500ms,Memory Limit:32768KB Total submit users:1140,Accepted users:771 Problem 10045 :No special judgement Problem description Persons, whose number order is from 1 to N, hold a password...原创 2020-12-16 20:46:31 · 552 阅读 · 0 评论 -
[HNU 10027] Longest Ordered Subsequence Extention
Longest Ordered Subsequence ExtentionTime Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:65536KBTotal submit users: 1521, Accepted users: 991Problem 10027 : No special judgementProblem descriptionA numeric sequence of ai is ordered if a1 <原创 2020-12-13 00:19:00 · 500 阅读 · 0 评论 -
[每日一题] 四平方和
#include <iostream>#include <cmath>using namespace std;int cal_square_sum(int i, int j, int k, int l) { return i*i + j*j + k*k + l*l;}int main() { int n = 0; cin >&g...原创 2020-04-11 20:54:44 · 112 阅读 · 0 评论 -
[每日一题] 02 对兔子的数目进行取模
#include <iostream>#include <cmath>using namespace std;int main() { int mod = pow(10, 9) + 7; int n = 0, x = 0, y = 0; cin >> n; x = y = 1; int tmp = 0; ...原创 2020-04-11 20:54:53 · 112 阅读 · 0 评论 -
[每日一题] 03 暴力6重循环解最大子数组和
#include <iostream>using namespace std;int main() { int n, m; cin >> n >> m; int arr[n][m]; for (int i = 0 ; i < n ; ++i) { for (int j = 0 ; j < m ; ...原创 2020-04-11 20:55:01 · 138 阅读 · 0 评论 -
图知识小结6-十字链表的数组实现与应用
十字链表是一种高效存储稀疏图并可以显著提高查找效率的一种存储结构,解决了图的遍历过程中邻接表空间消耗大而邻接矩阵求一个点入度又需要遍历全部表的问题,下面给出其数组实现://十字链表的数组实现 #include <bits/stdc++.h>using namespace std;const int MAX_EDGE = 10000;const int MAX_VER...原创 2018-12-11 12:19:12 · 333 阅读 · 0 评论 -
图知识小结6-DFS应用【CCF201709-4通信网络】
#include <bits/stdc++.h>using namespace std;const int MAX_EDGE = 10005;const int MAX_VERTICES = 1005;int conn[MAX_VERTICES][MAX_VERTICES]; //记录两个点之间的连通性质 struct Edge{ int v, last;} edge[...原创 2018-12-09 23:38:46 · 404 阅读 · 0 评论 -
图论知识小结1-使用数组模拟实现邻接表
//普通一维数组模拟实现const int MAX_N = 100;const int MAX_M = 10000;//建立MAX_N条边 struct edge{ int v; //当前边的终点 int last_eid; //上一条相同起点的边的编号 }edge[MAX_M]; int latest_eid_of_u[MAX_N], temp_eid; void ini...原创 2018-12-09 23:35:24 · 299 阅读 · 0 评论 -
【C++】CCF 201703-4 地铁修建 【从80分到100分的优化过程】
#include <bits/stdc++.h>using namespace std;const int MAX_EDGE = 200005;const int MAX_VERTICES = 100005;struct Edge{ int v, len, last;} edge[2 * MAX_EDGE]; //开始是80分,后来改了一下就对了,原因是无向图的边集上限...原创 2018-12-07 18:07:57 · 420 阅读 · 0 评论 -
图论知识小结4-Dijkstra的数组模拟实现
#include <bits/stdc++.h>using namespace std;const int MAX_EDGE = 10000;const int MAX_VERTICES = 100;struct Edge{ int len, v, last;} edgem[MAX_EDGE];int latest_edge_of_u[MAX_VERTICES];in...原创 2018-12-06 19:27:36 · 203 阅读 · 0 评论 -
图论知识小结3-BFS的数组模拟实现
#include <bits/stdc++.h>using namespace std;const int MAX_EDGE = 10000;const int MAX_VERTICES = 100;struct Edge{ int len, v, last;} edge[MAX_EDGE];int eid;bool vst[MAX_VERTICES];int la...原创 2018-12-06 17:48:28 · 222 阅读 · 0 评论 -
图论知识小结2-DFS的数组模拟实现
#include <bits/stdc++.h>using namespace std;const int MAX_EDGE = 10000;const int MAX_VERTICES = 100;struct Edge{ int len, v, last;} edge[MAX_EDGE];bool vst[MAX_VERTICES];int latest_edge...原创 2018-12-06 17:32:31 · 228 阅读 · 0 评论 -
图知识小结5-kruskal算法的数组模拟实现与应用
#include <bits/stdc++.h>using namespace std;const int MAX_EDGE = 100000;const int MAX_VERTICES = 100;struct Edge{ int len, u, v;} edge[MAX_VERTICES];int fa[MAX_VERTICES], nv, ne;bool cm...原创 2018-12-08 17:15:06 · 170 阅读 · 0 评论 -
[c++]Prim 算法伪代码和算法思想
Prim 算法明天数据结构期末考试,估计也不会考这些代码(每次就考怎么画图?总感觉我考了个假的数据结构)但是数据结构学到今天课本上也就是这个算法一直实现不了今天看了下课本,给的代码也不全,自己理解了一下,给出其完整的伪代码和各个部分的伪代码实现算法思想:和Dijkstra其实非常的类似不同的是,对于Dijkstra其每次更新距离数组的值是对于图中的每一个顶点,考察它与"当前最小...原创 2019-01-08 22:04:10 · 3634 阅读 · 0 评论 -
[C++]kruaskal的伪代码描述
既然给出了prim的,就顺便写一下Kruskal的伪代码描述:struct Edge{ int u, v, w; //u for starting point, v for end point, w for weight Edge(int u, int v, int w){ this->u = u; this->v = v; this->w = w; }...原创 2019-01-08 22:22:25 · 996 阅读 · 0 评论 -
[Python3]Bellman-Ford的实现及Yen式优化
原理分析见本人Github:https://github.com/youhengchan/Yen-Bellman-Ford/blob/master/group2_ppt_yen.pdf测试数据:原始算法:伪代码:实现:import timegraph_size = 10counter = 0class Edge: def __init__(s...原创 2019-06-11 22:27:03 · 1437 阅读 · 3 评论 -
[Python3]Sherwood 型线性时间选择算法
# sherwood algorithmimport timeimport randomdef time_calculate(): start = time.perf_counter() mid_value = main() end = time.perf_counter() return mid_value, end - startdef s...原创 2019-06-13 13:57:01 · 732 阅读 · 0 评论 -
[python]n皇后问题,输出所有解
import timecount = 0n = 8G = [] # the whole graphr = [] # each row's statusbl = [] # bottom left to top rightbr = [] # bottom right to top leftdef init(): global n n = int(inpu...原创 2019-05-27 19:54:13 · 1467 阅读 · 0 评论 -
[算法导论]第一章-读书笔记
这本书,非常的厚,对于本科生,有一定的难度,我希望通过这种读一章写一章笔记的方式,给自己啃下这本书的信心,我的想法是这样的,看书,看完马上写一个小结,然后做课后前3道习题(时间并不充裕,之后有需要再多做一些)2019/03/06第一章算法在计算中的作用散列表->搜索引擎字符串匹配->搜索引擎单源最短路径->互联网传输数据,交通路径数值算法 ->密...原创 2019-03-07 01:08:52 · 416 阅读 · 0 评论 -
[算法导论]学习笔记总目录
知乎对这本书的介绍:《算法导论》(英语 :Introduction to Algorithms)是基础算法方面最权威、最详细的著作之一,在很多国际著名大学被用于算法课的教材。诸多算法方面的论文将其列入参考文献当中。忽然意识到我湖一直是按照国际著名大学的标准要求自己的,没错,这就是我们的课本,许多科技公司现在的科技壁垒都在于算法,学好算法,从逼迫自己每天看书写博客开始,两个老师都是博士,助教...原创 2019-03-06 22:59:44 · 1386 阅读 · 0 评论 -
[Python3]闭包实现求阶乘和经典汉诺塔问题递归求解
首先是经典的汉诺塔问题:(写这个函数的时候,默认的是按照y为开始放有盘子的柱子,z为目标柱子,x为辅助柱子,n为盘子的总数)def hanoi(n, x, y, z): # y -> z is our goal, x is a helper if n == 1: print(y, "->", z) return hanoi(n-1, z, y, x) prin...原创 2019-03-05 17:14:04 · 284 阅读 · 0 评论