自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Akatsuki

愿你戎码一生,归来仍有头发。

  • 博客(257)
  • 收藏
  • 关注

原创 PAT 1038 Recover the Smallest Number(好题!字符串排序)

PAT10381038 Recover the Smallest Number (30 分)Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given { 32, 321, 3214, 0229, 87 }, we c...

2018-11-20 20:50:40 556

原创 PAT 1053 Path of Equal Weight(DFS+多级排序)

PAT10531053 Path of Equal Weight (30 分)Given a non-empty tree with root R, and with weight W​i​​ assigned to each tree node T​i​​. The weight of a path from R to L is defined to be the sum of the ...

2018-11-16 21:45:51 214

原创 PAT 1052 Linked List Sorting (结构体排序)

PAT10531052 Linked List Sorting (25 分)A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and a Ne...

2018-11-16 21:41:40 270

原创 PAT 1051 Pop Sequence(带边界限制的出栈序列)

PAT10511051 Pop Sequence (25 分)Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, ..., N and pop randomly. You are supposed to tell if a given sequence of numb...

2018-11-16 21:38:40 265

原创 PAT 1050 String Subtraction(字符串水题)

PAT10501050 String Subtraction (20 分)Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the remaining string after taking all the characters in S​2​​ from S​1​​. Your task is simply...

2018-11-16 21:31:07 214

原创 优先队列的两种自定义排序方式

首先简单的优先队列的定义方法有三种1.默认从大到小排序priority_queue<int>q;2.等价于上面(从大到小排序)priority_queue<int,vector<int>,less<int> >q;//注意这里最后的两个>要分开3.定义从小到大排序的优先队列priority_queue<int...

2018-11-16 17:06:23 4491 2

原创 PAT 1017 Queueing at Bank(排序+优先队列)

PAT10171017 Queueing at Bank (25 分)Suppose a bank has K windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. All the customers ha...

2018-11-14 20:11:38 272

原创 HDU 2586 How far away ?(LCA Tarjan/树上倍增)

HDU2586题目:问任意两个点之间的最短路径长。如果用Tarjan做的话,那么用LCA算出最近公共祖先lca,长度就是dis[u]+dis[v]-2*dis[lca]#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<v...

2018-11-12 20:42:25 282

原创 HDU 3966 Aragorn's Story(树链剖分+线段树)

HDU3966三种操作:路径上所有点的人数+v;路径上所有点的人数-v;求某个节点x的人数树链剖分的点权操作,以及单点查询。#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<cmath>#include<al...

2018-11-12 20:35:07 250

原创 PAT 1015 Reversible Primes(进制转换+素数判断)

PAT 10151015 Reversible Primes (20 分)A reversible prime in any number system is a prime whose "reverse" in that number system is also a prime. For example in the decimal system 73 is a reversible ...

2018-11-12 20:20:34 293

原创 JSP中将字符串转换为double类型问题

假设我们现有 String str = "1.23456789"欲强制转换为double类型double res = Double.parseDouble(str);完。

2018-11-10 10:17:34 5612

原创 PAT 1011 World Cup Betting(水题)

PAT10111011 World Cup Betting (20 分)With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles for ...

2018-11-08 18:12:39 260

原创 PAT 1012 The Best Rank(多级排序)

PAT10121012 The Best Rank (25 分)To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Programming Language, M - Mathematics (Calc...

2018-11-08 18:11:15 374

原创 PAT 1013 Battle Over Cities(DFS统计连通图的个数)

PAT10131013 Battle Over Cities (25 分)It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are c...

2018-11-07 09:25:34 259

原创 PAT 1025 PAT Ranking(排序)

PAT 10251025 PAT Ranking (25 分)Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run simultaneously in ...

2018-11-02 21:31:21 407

原创 PAT 1024 Palindromic Number(Java大数模拟)

PAT10241024 Palindromic Number (25 分)A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All sin...

2018-11-02 21:28:42 273

原创 PAT 1023 Have Fun with Numbers(Java大数模拟)

PAT10231023 Have Fun with Numbers (20 分)Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, wh...

2018-11-02 21:26:29 233

原创 PAT 1009 Product of Polynomials(模拟多项式相乘)

PAT1009This time, you are supposed to find A×B where A and B are two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, and each line contains th...

2018-11-02 16:07:14 207

原创 PAT 1008 Elevator)

PAT10081008 Elevator (20 分)The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in ...

2018-10-29 12:45:34 129

原创 CSDN吐槽-

好几天登不上博客了,本地的手机号欠费了,本来这个号平常也用不到所以就懒得冲,结果CSDN也登不上去了,需要我的手机号码验证。刚刚把花费冲上之后,又不需要验证,可以直接登录了?巧合吗?CSDN这是和移动合作了吗?手机欠费CSDN也登不上,充上话费立马又能登录了?好恶心。...

2018-10-28 19:45:31 268

原创 PAT 1007 Maximum Subsequence Sum(dp)

PAT1007Given a sequence of K integers { N​1​​, N​2​​, ..., N​K​​ }. A continuous subsequence is defined to be { N​i​​, N​i+1​​, ..., N​j​​ } where 1≤i≤j≤K. The Maximum Subsequence is the continuous ...

2018-10-22 15:37:16 149

原创 PAT 1006 Sign In and Sign Out(排序水题)

PAT1006At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the records of signing in's and o...

2018-10-22 15:34:44 144

原创 PAT 1005 Spell It Right

PAT10051005 Spell It Right (20 分)Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English.Input Specification:Each i...

2018-10-20 10:06:16 120

原创 PAT 1004 Counting Leaves(分层+统计每层叶子节点数)

PAT10041004 Counting Leaves (30 分)A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.Input Specification:Each input file co...

2018-10-20 10:04:55 348

原创 PAT 1003 Emergency(SPFA+dfs回溯记录最短路径条数)

PAT10031003 Emergency (25 分)As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of res...

2018-10-19 09:53:37 732

原创 PAT 1002 A+B for Polynomials

PAT 10021002 A+B for Polynomials (25 分)This time, you are supposed to find A+B where A and B are two polynomials.Input Specification:Each input file contains one test case. Each case occupies ...

2018-10-18 17:34:36 114

原创 PAT 1001 A+B Format

PAT 1001PAT甲级第一道题,争取每道题无论水浅或深,都坚持写一篇博客。1001 A+B Format (20 分)Calculate a+b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless t...

2018-10-18 13:08:27 298

原创 codeblocks更新编译器(minGW的下载及安装配置)

拖延症后期终于要把两年前的编译器更新了...找到安装codeblocks的文件目录里,找到minGW文件,这个文件包含GCC编译器和GDB调试器IDM-GCC刚刚更新到最新版本6.3.0,更新前是4.7.x....了如何查看自己minGW的版本?找到codeblocks的安装目录,进入到在此文件目录下进入dos命令窗,输入 gcc -v,如下图 更新minGW...

2018-10-18 12:56:04 9274 1

原创 HDU2222(AC自动机模板)

HDU2222物联网课- - 又看了一遍AC自动机。有趣kuangbin巨巨的模板#include<cstdio>#include<cstring>#include<queue>using namespace std;const int N=26;const int MAXN=500005;struct Trie{ int ...

2018-10-10 17:05:48 308

原创 java学习笔记-多线程编程模拟十个人过山洞

编写多线程应用程序,模拟多个人通过一个山洞的模拟。这个山洞每次只能通过一个人,每个人通过山洞的时间为5秒,随机生成10个人,同时准备过此山洞,显示一下每次通过山洞人的姓名。 使用线程同步,把山洞看做临界资源,五秒内只允许一个人来访问。class cave { public synchronized void action(String name) { System.out.pr...

2018-10-08 19:05:00 825

原创 最小费用最大流

poj2135模板题意:有n个点,m条边,FJ要从1走到n,再从n走回1,走的边不能重复,找这样一个来回的最短路径。转为最小费用最大流来做,也就是说每条边只能用一次,我们把给出的每条边的长度作为这条边的花费,然后设边的容量为1因为是无向图,所以对于每条边(x,y)要建立四条边,x->y容量为1费用为L(长度)的边,y->x容量为0费用为(-L)的边,y->x容...

2018-10-04 17:50:33 397

原创 HDU2444(二分图的最大匹配+染色法判断二分图)

HDU2444 n=200,边要开到1e5才能过。。。。。。 #include<iostream>#include<cstdio>#include<cstring>#include<queue>#define eps 1e-8#define memset(a,v) memset(a,v,sizeof(a))using n...

2018-10-02 19:02:40 239

原创 求最近公共祖先(LCA)的三种方法总结(Tarjan/倍增/树链剖分)

以模板题目poj1330为例 DescriptionA rooted tree is a well-known data structure in computer science and engineering. An example is shown below:  In the figure, each node is labeled with an integer from ...

2018-09-25 16:35:04 199

原创 HDU2586-How far away ?(离线Tarjan + 倍增)

Problem DescriptionThere are n houses in the village and some bidirectional roads connecting them. Every day peole always like to ask like this "How far is it if I want to go from house A to house B...

2018-09-25 15:56:17 228

原创 2.3.1 Longest Prefix 最长前缀(字典树)

Description在生物学中,一些生物的结构是用包含其要素的大写字母序列来表示的。生物学家对于把长的序列分解成较短的(称之为元素的)序列很感兴趣。 如果一个集合 P 中的元素可以通过串联(允许重复;串联,相当于 Pascal 中的 “+” 运算符)组成一个序列 S ,那么我们认为序列 S 可以分解为 P 中的元素。并不是所有的元素都必须出现。举个例子,序列 ABABACABAAB 可以分解...

2018-09-19 17:50:05 843

原创 The 2018 ACM-ICPC (青岛)-H题-Traveling on the Axis(找规律+前缀和)

好几个题的代码都找不到了,写一写打开cb唯一剩的一道题的代码吧。题目链接 1代表绿灯,0代表红灯。红灯的时候要等一秒,绿灯可以直接通过,穿过一个灯也需要耗费一秒钟。问耗费的总时间。具体计算方法见题目的hint......( 思路:算是找了下规律,规律如下:第一个灯如果为1,那么通过的时间为1秒,如果为0,那么时间需要两秒。从第二个灯开始,如果当前灯的状态...

2018-09-17 17:01:33 685 5

原创 java多线程编程--模拟龟兔赛跑过程

 刚开始学多线程编程,课上也没认真听,课下去网上找了PPT,又认真的学了一遍。问题:编写龟兔赛跑多线程程序,设赛跑长度为100米,每跑完10米输出一次结果。 采用实现Runnable接口的方法编写龟兔赛跑多线程程序,功能与1完全一样。 改进1的龟兔赛跑程序,通过改变优先级,并减掉休眠时间,使得乌龟以迅雷不及掩耳的速度跑完100米。 编写兔子休眠后被乌龟中断(吵醒)的多线程程序。...

2018-09-16 11:08:21 8224

原创 HDU 3966-Aragorn's Story(树链剖分,区间修改+点权)

题目链接 第一道链剖的题目,从早晨七点到图书馆开始写,写了一上午,才把树链剖开。晚上开始边看明日之子的直播听他们唱歌,边维护线段树(下午做了一场多校)debug了无数次之后,终于写对了。还是挺开心的,因为代码都是自己写的。 题意:给一棵树,每个节点都有一个权值。有三种操作:I:x y v 将x到y路径中的所有节点的权值都加上vD:x y v 将x到y路径中的...

2018-09-14 22:21:20 422

原创 HDU 3416-Marriage Match IV(最短路+最大流)

HDU 3416 很好的一道题,求的是没有交集的最短路的条数。正向反向跑两边SPFA之后,对于输入的边,如果此条边在最短路上,那么就将它的容量+1,最后根据重新构造的图跑一遍最大流。 有意思的是这道题卡了我之前写的一个dinic算法的模板,具体代码可见:这里 代码如下:#include<iostream>#include<cstdio>...

2018-09-13 11:41:55 243

原创 2.4.4 Bessie Come Home 回家

Description现在是晚餐时间,而母牛们在外面分散的牧场中。 农民约翰按响了电铃,所以她们开始向谷仓走去。 你的工作是要指出哪只母牛会最先到达谷仓(在给出的测试数据中,总会有且只有一只速度最快的母牛)。 在挤奶的时候(晚餐前),每只母牛都在她自己的牧场上,一些牧场上可能没有母牛。 每个牧场由一条条道路和一个或多个牧场连接(可能包括自己)。 有时,两个牧场(可能是自我相同的)之间会有超过一...

2018-09-08 21:26:00 446

空空如也

空空如也

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

TA关注的人

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