摘要: 题目地址:https://www.luogu.com.cn/problem/P1575 题意:给出一个字符串,其中只有true、false、and、not、or这五种字符,其中运算符的优先级是not>and>or,输出最后表达式的结果true或者false。当然,如果表达式本身就是一个错误的表达式( 阅读全文
posted @ 2020-08-06 01:42 白菜茄子 阅读(287) 评论(0) 推荐(0) 编辑
摘要: 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=6797 题意:有n个点的完全无向图,也就是有n(n-1)/2条无向边,删除k条边之后使得从一号节点到n号节点的最短路径最长,求出次最短路径的最大值 输入:第一行一个整数t,表示样例个数 每个样例第一行两个 阅读全文
posted @ 2020-07-31 14:23 白菜茄子 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 队列:先进先出 头文件:<queue> 基本操作: queue<Type>q; //定义队列,Type可以系统定义的数据类型,也可以是自己定义的结构体类型 q.push(item); //把item放入队列的尾部 q.front(); //返回队首元素,但不会删除 q.pop(); //删除队首元素 阅读全文
posted @ 2020-07-31 11:59 白菜茄子 阅读(566) 评论(0) 推荐(0) 编辑
摘要: 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=6795 题意:有n个人,分为两类,一类为权值为1的人,一类为权值为2的人。起初,这n个人互不相识,然后又n-1此介绍,每次介绍u与v相识(在这之前u,v并不认识,若a认识b,b认识c,则a也认为认识c), 阅读全文
posted @ 2020-07-29 19:34 白菜茄子 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=6763 题目大意:有一个n个点m条边的无向图,结点从1开始编号到n,每个结点都有一个权值bi,现在希望可以将所有结点的权值改为0 可以进行下面的操作: 1:选择一个正整数k(1<=k<=n) 2:选择k个 阅读全文
posted @ 2020-07-23 23:02 白菜茄子 阅读(204) 评论(0) 推荐(0) 编辑
摘要: LCA最近公共祖先 LCA:树上两个结点的最近公共祖先 适用于求树上某条路径相关的一些问题 方法一:暴力求解 原理:对于已知每个结点的父亲结点的树,要求x和y的LCA,首先让深度更深的结点,此处 不妨设为y,向上跳到与x同样的深度,然后两个结点再同时往上跳,直至重合,这个重合的结点就是x和y的LCA 阅读全文
posted @ 2020-04-24 18:24 白菜茄子 阅读(912) 评论(0) 推荐(0) 编辑
摘要: HTTP协议及Requests库的方法 HTTP: Hypertext Transfer Protocol,超文本传输协议 HTTP是一个基于“请求与响应”模式的、无状态的应用层协议。也就是用户发出请求,服务器给出响应。无状态是指第一次请求与第二次请求之间并没有相关关联。应用层协议工作在TCP协议之 阅读全文
posted @ 2020-04-16 23:19 白菜茄子 阅读(672) 评论(0) 推荐(0) 编辑
摘要: 一:安装第三方库requests 首先打开命令提示符(以管理员身份运行) 输入pip install requests,然后回车 首次安装的时候出现了问题 百度之后是说版本太低 按照上面的提示更新pip还是显示WARNING,最后卸载python,重新安装python,再更新pip就可以了,可能是电 阅读全文
posted @ 2020-04-15 21:36 白菜茄子 阅读(699) 评论(0) 推荐(0) 编辑
摘要: 网址:https://codeforces.ml/contest/1333/problem/C 题目描述: Eugene likes working with arrays. And today he needs your help in solving one challenging task. 阅读全文
posted @ 2020-04-09 16:52 白菜茄子 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 网址:https://codeforces.ml/contest/1330/problem/B 题目描述:The sequence of m integers is called the permutation if it contains all integers from 1 to m exac 阅读全文
posted @ 2020-04-04 23:12 白菜茄子 阅读(292) 评论(0) 推荐(0) 编辑
摘要: Problem Description Consider a un-rooted tree T which is not the biological significance of tree or plant, but a tree as an undirected graph in graph 阅读全文
posted @ 2019-10-23 12:38 白菜茄子 阅读(196) 评论(0) 推荐(0) 编辑
摘要: Problem Description Avin meets a rich customer today. He will earn 1 million dollars if he can solve a hard problem. There are n warehouses and m work 阅读全文
posted @ 2019-10-17 11:19 白菜茄子 阅读(263) 评论(0) 推荐(0) 编辑
摘要: Problem Description Avin’s company has many ongoing projects with different budgets. His company records the budgets using numbers rounded to 3 digits 阅读全文
posted @ 2019-10-16 21:16 白菜茄子 阅读(201) 评论(0) 推荐(0) 编辑
摘要: Problem Description Avin is studying series. A series is called "wave" if the following conditions are satisfied:1) It contains at least two elements; 阅读全文
posted @ 2019-10-14 22:05 白菜茄子 阅读(215) 评论(0) 推荐(0) 编辑
摘要: Description Bessie noted that although humans have many universities they can attend, cows have none. To remedy this problem, she and her fellow cows 阅读全文
posted @ 2019-09-27 19:52 白菜茄子 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=1258 Description Farmer John has been elected mayor of his town! One of his campaign promises was to bring internet con 阅读全文
posted @ 2019-09-05 11:10 白菜茄子 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=2377 Description Bessie has been hired to build a cheap internet network among Farmer John's N (2 <= N <= 1,000) barns 阅读全文
posted @ 2019-09-05 11:05 白菜茄子 阅读(189) 评论(0) 推荐(0) 编辑
摘要: Description Fermat's theorem states that for any prime number p and for any integer a > 1, ap = a (mod p). That is, if we raise a to the pth power and 阅读全文
posted @ 2019-09-04 21:15 白菜茄子 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 素数筛:需要一个数组进行标记 最小的素数2,所有是2的倍数的数都是合数,对合数进行标记,然后找大于2的第一个非标记的数(肯定是素数),将其倍数进行标记,如此反复,若是找n以内的所有素数,只需要对[2,n^0.5]进行循环即可,因为n以内的所有数如果不是[2,n^0.5]的倍数,则一定是素数。复杂度: 阅读全文
posted @ 2019-09-04 11:29 白菜茄子 阅读(179) 评论(0) 推荐(0) 编辑
摘要: Description An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, 阅读全文
posted @ 2019-08-30 19:46 白菜茄子 阅读(199) 评论(0) 推荐(0) 编辑
摘要: Description To avoid unsightly burns while tanning, each of the C (1 ≤ C ≤ 2500) cows must cover her hide with sunscreen when they're at the beach. Co 阅读全文
posted @ 2019-08-29 21:02 白菜茄子 阅读(181) 评论(0) 推荐(0) 编辑
摘要: Description There is a pile of n wooden sticks. The length and weight of each stick are known in advance. The sticks are to be processed by a woodwork 阅读全文
posted @ 2019-08-28 22:02 白菜茄子 阅读(181) 评论(0) 推荐(0) 编辑
摘要: People in Silverland use coins.They have coins of value A1,A2,A3...An Silverland dollar.One day Tony opened his money-box and found there were some co 阅读全文
posted @ 2019-08-28 11:48 白菜茄子 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。 有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是"1 X Y",表示X和Y是同类。 第二种 阅读全文
posted @ 2019-08-26 19:53 白菜茄子 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 描述 大表哥分配 N (1 include include using namespace std; int t[1000005]; //t[i]表示以i开始的所有的牛中结束最晚的牛的值 int main(){ int N,T; while(cin N T){ memset(t, 1,sizeof( 阅读全文
posted @ 2019-08-26 14:34 白菜茄子 阅读(324) 评论(0) 推荐(0) 编辑
摘要: escription 题目描述 给定若干位十进制数,你可以通过选择一个非空子集并以某种顺序构建一个数。剩余元素可以用相同规则构建第二个数。除非构造的数恰好为0,否则不能以0打头。 举例来说,给定数字0,1,2,4,6与7,你可以写出10和2467。当然写法多样:210和764,204和176,等等。 阅读全文
posted @ 2019-08-26 14:01 白菜茄子 阅读(160) 评论(0) 推荐(0) 编辑
摘要: Description 题目描述 Bessie听说有场史无前例的流星雨即将来临;有谶言:陨星将落,徒留灰烬。为保生机,她誓将找寻安全之所(永避星坠之地)。目前她正在平面坐标系的原点放牧,打算在群星断其生路前转移至安全地点。 此次共有M (1 ≤ M ≤ 50,000)颗流星来袭,流星i将在时间点Ti 阅读全文
posted @ 2019-08-26 13:58 白菜茄子 阅读(133) 评论(0) 推荐(0) 编辑
摘要: A group of cows grabbed a truck and ventured on an expedition deep into the jungle. Being rather poor drivers, the cows unfortunately managed to run o 阅读全文
posted @ 2019-08-22 15:47 白菜茄子 阅读(96) 评论(0) 推荐(0) 编辑
摘要: Problem Description Given a rectangle frame of size n×m. Initially, the frame is strewn with n×m square blocks of size 1×1. Due to the friction with t 阅读全文
posted @ 2019-08-22 10:35 白菜茄子 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 给定一个字符串S,字符串S的长度为M(M≤2000),字符串S所含有的字符的种类的数量为N(N≤26),然后给定这N种字符Add与Delete的代价,求将S变为回文串的最小代价和。 Input 第一行:两个由空格分隔的整数 N 和 M 第二行:这一行给出了恰好 M 个字符,表示初始状态下的ID字符串 阅读全文
posted @ 2019-08-20 21:15 白菜茄子 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 有N堆石子,现要将石子有序的合并成一堆,规定如下:每次只能移动相邻的2堆石子合并,合并花费为新合成的一堆石子的数量。求将这N堆石子合并成一堆的总花费最小。 区间DP思想:现在小区间进行DP得到最优解,然后再利用小区间的最优解组合并求大区间的最优解。(需要从小到大枚举所有可能的区间) 代码(没提交过, 阅读全文
posted @ 2019-08-20 19:37 白菜茄子 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 7 3 8 8 1 0 2 7 4 4 4 5 2 6 5 (Figure 1) Figure 1 shows a number triangle. Write a program that calculates the highest sum of numbers passed on a rout 阅读全文
posted @ 2019-08-20 16:19 白菜茄子 阅读(170) 评论(0) 推荐(0) 编辑
摘要: Problem Description A little frog named Fog is on his way home. The path's length is N (1 = 1). The next line contains N integers, describing the numb 阅读全文
posted @ 2019-08-20 16:15 白菜茄子 阅读(382) 评论(0) 推荐(0) 编辑
摘要: Problem Description A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = <x1, x2, 阅读全文
posted @ 2019-08-18 17:38 白菜茄子 阅读(169) 评论(0) 推荐(0) 编辑
摘要: Problem Description Many years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to collect varies of bones , s 阅读全文
posted @ 2019-08-18 16:32 白菜茄子 阅读(192) 评论(0) 推荐(0) 编辑
摘要: Problem Description Suppose there are 5 types of coins: 50-cent, 25-cent, 10-cent, 5-cent, and 1-cent. We want to make changes with these coins for a 阅读全文
posted @ 2019-08-18 10:43 白菜茄子 阅读(866) 评论(0) 推荐(0) 编辑
摘要: 动态规划:多阶段决策问题,每步求解的问题是后面阶段问题求解的子问题,每步决策将依赖于以前步骤的决策结果。(可以用于组合优化问题) 优化原则:一个最优决策序列的任何子序列本身一定是相当于子序列初始和结束状态的最优决策序列。 只有满足优化原则的问题才可以利用动态算法进行求解,因为只有全局最优解法等于其每 阅读全文
posted @ 2019-08-17 10:45 白菜茄子 阅读(176) 评论(0) 推荐(0) 编辑
摘要: Huffman树:具有n个外部节点(叶子节点)的二叉树 每个外部节点都有一个对应的权值Wi 叶节点带权外部路径长度总和WPL=Wi*Li(i从1到n)最小(权越大的节点里根越进) 构造Huffman树:1)根据给定的n个权值{W1,W2,W3......Wn}构成n棵二叉树的集合F={T1,T2,T 阅读全文
posted @ 2019-08-16 16:13 白菜茄子 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 给定长度为N(1≤N≤2000)的字符串S,要构造一个长度为N的字符串T。期初,T是一个空串,随后反复进行下列任意操作。 ·从S的头部删除一个字符,加到T的尾部 ·从S的尾部删除一个字符,加到T的尾部 目标是要构造字典序尽可能小的字符串 给定长度为N(1≤N≤2000)的字符串S,要构造一个长度为N 阅读全文
posted @ 2019-08-15 16:58 白菜茄子 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 归并排序:简而言之就是利用递归分治的思想。将一个无序的数列,利用二分分成两个数列,依此递推直到每个小数列的元素个数都是1的时候,然后让两个是一个父亲的数列,进行排序,刚开始每个数列为1,直接比较大小排序,然后往后回归形成的每个大数列都是有序的,让他们开头依此比较进行排序。 复杂度为O(nlogn) 阅读全文
posted @ 2019-08-15 10:50 白菜茄子 阅读(226) 评论(0) 推荐(0) 编辑