自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 GCD and LCM

 Given two positive integers G and L, could you tell me how many solutions of (x, y, z) there are, satisfying that gcd(x, y, z) = G and lcm(x, y, z) = L?Note, gcd(x, y, z) means the greatest common...

2018-12-31 15:16:16 155

原创 D-City

 Luxer is a really bad guy. He destroys everything he met.One day Luxer went to D-city. D-city has N D-points and M D-lines. Each D-line connects exactly two D-points. Luxer will destroy all the D-li...

2018-12-31 15:11:42 293

原创 Tutor

 Lilin was a student of Tonghua Normal University. She is studying at University of Chicago now. Besides studying, she worked as a tutor teaching Chinese to Americans. So, she can earn some money pe...

2018-12-31 15:06:45 200

原创 图着色问题 (25 分)

7-38 图着色问题 (25 分)图着色问题是一个著名的NP完全问题。给定无向图G=(V,E),问可否用K种颜色为V中的每一个顶点分配一种颜色,使得不会有两个相邻顶点具有同一种颜色?但本题并不是要你解决这个着色问题,而是对给定的一种颜色分配,请你判断这是否是图着色问题的一个解。输入格式:输入在第一行给出3个整数V(0<V≤500)、E(≥0)和K(0<K≤V),分别是无...

2018-12-29 20:39:38 674

原创 排座位 (25 分)

7-40 排座位 (25 分)布置宴席最微妙的事情,就是给前来参宴的各位宾客安排座位。无论如何,总不能把两个死对头排到同一张宴会桌旁!这个艰巨任务现在就交给你,对任何一对客人,请编写程序告诉主人他们是否能被安排同席。输入格式:输入第一行给出3个正整数:N(≤100),即前来参宴的宾客总人数,则这些人从1到N编号;M为已知两两宾客之间的关系数;K为查询的条数。随后M行,每行给出一对宾客之...

2018-12-29 20:11:13 135

原创 列出连通集 (25 分)

7-39 列出连通集 (25 分)给定一个有N个顶点和E条边的无向图,请用DFS和BFS分别列出其所有的连通集。假设顶点从0到N−1编号。进行搜索时,假设我们总是从编号最小的顶点出发,按编号递增的顺序访问邻接点。输入格式:输入第1行给出2个整数N(0<N≤10)和E,分别是图的顶点数和边数。随后E行,每行给出一条边的两个端点。每行中的数字之间用1空格分隔。输出格式:按照"...

2018-12-29 19:43:28 939

原创 功夫传人 (25 分)

7-42 功夫传人 (25 分)一门武功能否传承久远并被发扬光大,是要看缘分的。一般来说,师傅传授给徒弟的武功总要打个折扣,于是越往后传,弟子们的功夫就越弱…… 直到某一支的某一代突然出现一个天分特别高的弟子(或者是吃到了灵丹、挖到了特别的秘笈),会将功夫的威力一下子放大N倍 —— 我们称这种弟子为“得道者”。这里我们来考察某一位祖师爷门下的徒子徒孙家谱:假设家谱中的每个人只有1位师傅(除...

2018-12-29 19:15:12 203

原创 Fox And Names(拓扑排序)

题目链接:http://codeforces.com/problemset/problem/510/C?csrf_token=baadfd2935ac90d344554ddd90621166Input3rivestshamiradlemanOutputbcdefghijklmnopqrsatuvwxyzInput10touristpetrwjmzbmryeputons...

2018-12-29 00:42:12 141

原创 Powers Of Two(二进制拆分)

题目链接:http://codeforces.com/contest/1095/problem/CExamplesinput9 4outputYES1 2 2 4input8 1outputYES8input5 1outputNOinput3 7outputNO题意:n能否拆成k个2的整数次方相加,如果能输出YES以及一种拆法,否则输出NO思路:先找出n...

2018-12-28 01:49:23 1099

原创 A hard Aoshu Problem (暴力模拟)

Math Olympiad is called “Aoshu” in China. Aoshu is very popular in elementary schools. Nowadays, Aoshu is getting more and more difficult. Here is a classic Aoshu problem:ABBDE __ ABCCC = BDBDEIn th...

2018-12-27 00:35:49 242

原创 Fermat Point in Quadrangle(求四边形费马点)(玄学模拟退火)

In geometry the Fermat point of a triangle, also called Torricelli point, is a point such that the total distance from the three vertices of the triangle to the point is the minimum. It is so named be...

2018-12-26 21:54:03 2145

原创 7-41 红色警报 (25 分)(并查集暴力)

7-41 红色警报 (25 分)战争中保持各个城市间的连通性非常重要。本题要求你编写一个报警程序,当失去一个城市导致国家被分裂为多个无法连通的区域时,就发出红色警报。注意:若该国本来就不完全连通,是分裂的k个区域,而失去一个城市并不改变其他城市之间的连通性,则不要发出警报。输入格式:输入在第一行给出两个整数N(0 < N ≤ 500)和M(≤ 5000),分别为城市个数(于是默认城市从...

2018-12-23 21:31:15 222

原创 博弈整理

巴什博弈只有一堆n个物品,两个人轮流从这堆物品中取物,规定每次至少取一个,最多取m个。最后取光者得胜。n%(m+1)==0,则后手胜利反巴什博弈只有一堆n个物品,两个人轮流从这堆物品中取物,规定每次至少取一个,最多取m个。最后取光者输(n-1)%(m+1)==0,则后手胜利Nim博弈通常的Nim游戏的定义是这样的:有若干堆石子,每堆石子的数量都是有限的,合法的移动是“选择一堆石子并拿...

2018-12-23 16:57:55 196

原创 hdu-5754 Life Winner Bo(混合博弈)

Bo is a “Life Winner”.He likes playing chessboard games with his girlfriend G.The size of the chessboard is N×MN×M.The top left corner is numbered(1,1)(1,1)and the lower right corner is numberd (N,...

2018-12-23 16:36:08 172

原创 poj-2425 A Chess Game (SG函数模板)

Let’s design a new chess game. There are N positions to hold M chesses in this game. Multiple chesses can be located in the same position. The positions are constituted as a topological graph, i.e. th...

2018-12-23 15:05:42 250

原创 7-37 城市间紧急救援 (25 分)(多权值最短路)(最优最短路路径,最短路条数)(Dijkstra)

7-37 城市间紧急救援 (25 分)作为一个城市的应急救援队伍的负责人,你有一张特殊的全国地图。在地图上显示有多个分散的城市和一些连接城市的快速道路。每个城市的救援队数量和每一条连接两个城市的快速道路长度都标在地图上。当其他城市有紧急求助电话给你的时候,你的任务是带领你的救援队尽快赶往事发地,同时,一路上召集尽可能多的救援队。输入格式:输入第一行给出4个正整数N、M、S、D,其中N(2≤N...

2018-12-22 01:43:14 218

原创 7-36 旅游规划 (25 分)(多权值最短路)(Dijkstra)

7-36 旅游规划 (25 分)有了一张自驾旅游路线图,你会知道城市间的高速公路长度、以及该公路要收取的过路费。现在需要你写一个程序,帮助前来咨询的游客找一条出发地和目的地之间的最短路径。如果有若干条路径都是最短的,那么需要输出最便宜的一条路径。输入格式:输入说明:输入数据的第1行给出4个正整数N、M、S、D,其中N(2≤N≤500)是城市的个数,顺便假设城市的编号为0~(N−1);M是高速...

2018-12-20 20:13:02 260

原创 Appearance Count(水题)

You will be given m strings. For each of those strings, you need to count the total number of appearances of that string as substrings in all possible strings of length n containing only lower case En...

2018-12-19 21:44:02 302

原创 哥尼斯堡的“七桥问题”(欧拉回路)

7-12 哥尼斯堡的“七桥问题” (25 分)哥尼斯堡是位于普累格河上的一座城市,它包含两个岛屿及连接它们的七座桥,如下图所示。可否走过这样的七座桥,而且每桥只走过一次?瑞士数学家欧拉(Leonhard Euler,1707—1783)最终解决了这个问题,并由此创立了拓扑学。这个问题如今可以描述为判断欧拉回路是否存在的问题。欧拉回路是指不令笔离开纸面,可画过图中每条边仅一次,且可以回到起点的...

2018-12-17 09:41:46 731

原创 7-14 拯救007 (25 分)(暴力)(并查集)

7-14 拯救007 (25 分)在老电影“007之生死关头”(Live and Let Die)中有一个情节,007被毒贩抓到一个鳄鱼池中心的小岛上,他用了一种极为大胆的方法逃脱 —— 直接踩着池子里一系列鳄鱼的大脑袋跳上岸去!(据说当年替身演员被最后一条鳄鱼咬住了脚,幸好穿的是特别加厚的靴子才逃过一劫。)设鳄鱼池是长宽为100米的方形,中心坐标为 (0, 0),且东北角坐标为 (50, 5...

2018-12-17 09:34:11 1683

原创 任务调度的合理性(拓扑排序裸题)

7-13 任务调度的合理性 (25 分)假定一个工程项目由一组子任务构成,子任务之间有的可以并行执行,有的必须在完成了其它一些子任务后才能执行。“任务调度”包括一组子任务、以及每个子任务可以执行所依赖的子任务集。比如完成一个专业的所有课程学习和毕业设计可以看成一个本科生要完成的一项工程,各门课程可以看成是子任务。有些课程可以同时开设,比如英语和C程序设计,它们没有必须先修哪门的约束;有些课程则...

2018-12-17 08:07:18 358

原创 I'm Bored!(水题,模拟???)

Being a judge is not always an interesting job! For example, it is very boring to wait for the first submission in the contest. So, judges used to entertain themselves using the “I’m Bored” tab in the...

2018-12-16 16:43:11 529

原创 Minimax (预处理)(枚举)

You are given a grid consisting of n rows each of which is dived into m columns. The rows are numbered from 1 to n from top to bottom, and the columns are numbered from 1 to m from left to right. Each...

2018-12-16 15:37:22 262

原创 Even Numbers(找规律)(组合数杨辉三角)(二进制)

Yousef loves playing with functions in his free time. Today, he invents the following function:Yousef will give you a list of queries, and you need to find the answers for them. For each query, you ...

2018-12-16 14:41:31 1144

原创 Cyclic Shift(字符串匹配水题)

You are given two strings a and b of the same length and consisting of lowercase English letters. You can pick at most one subsequence of string b and do a cyclic shift on that subsequence exactly onc...

2018-12-16 13:41:16 827

原创 Stupid Submissions(模拟)

Abed is so motivated this year, his goal is qualifying for the 2019 ACM International Collegiate Programming Contest (ACM ICPC). Therefore, he always trains using Codeforces online judge. If you do no...

2018-12-16 13:35:17 476

原创 Shortest Path!(最短路模拟)

Today, Husam was visiting his grandmother. Husam always takes a path such that the total distance he will walk is as minimum as possible. Husam decided to give you all information about his journey so...

2018-12-16 13:02:31 1212

原创 Multiplication Dilemma(乘法技巧模拟)

Multiplication operation is not always easy! For example, it is hard to calculate 27 × 20 using your mind, but it is easier to find the answer using the following methods: 30 × 20 - 3 × 20. It turns o...

2018-12-16 12:54:07 700

原创 Beautiful Substrings(预处理)(思维 + 后缀和)

You are given two strings a and b consisting of lowercase English letters. A beautiful substring is defined as a substring of any length of string b such that the first and last letters of it are the ...

2018-12-16 12:03:19 278

原创 Max Sum Plus Plus (DP有点难)

Now I think you have got an AC in Ignatius.L’s “Max Sum” problem. To be a brave ACMer, we always challenge ourselves to more difficult problems. Now you are faced with a more difficult problem.Given ...

2018-12-13 20:55:52 275

原创 Dollars (离线dp)

Problem问题New Zealand currency consists of $100, $50, $20, $10, and $5 notes and $2, $1, 50c, 20c, 10c and 5c coins. Write a program that will determine, for any given amount, in how many ways that a...

2018-12-11 20:55:26 544

原创 The Fewest Coins (多重背包+完全背包)(鸽巢原理)

Farmer John has gone to town to buy some farm supplies. Being a very efficient man, he always pays for his goods in such a way that the smallest number of coins changes hands, i.e., the number of coin...

2018-12-11 19:55:53 455

原创 1028 人口普查 (20 分)

1028 人口普查 (20 分)某城镇进行人口普查,得到了全体居民的生日。现请你写个程序,找出镇上最年长和最年轻的人。这里确保每个输入的日期都是合法的,但不一定是合理的——假设已知镇上没有超过 200 岁的老人,而今天是 2014 年 9 月 6 日,所以超过 200 岁的生日和未出生的生日都是不合理的,应该被过滤掉。输入格式:输入在第一行给出正整数 N,取值在(0,10^5];随后 N ...

2018-12-11 18:04:33 119

原创 Constructing Roads In JGShining's Kingdom(思维+NlogN求最长上升子序列)(好题)

JGShining’s kingdom consists of 2n(n is no more than 500,000) small cities which are located in two parallel lines.Half of these cities are rich in resource (we call them rich cities) while the other...

2018-12-11 17:38:50 219

原创 Monkey and Banana(DP 二维最长下降子序列)

A group of researchers are designing an experiment to test the IQ of a monkey. They will hang a banana at the roof of a building, and at the mean time, provide the monkey with some blocks. If the monk...

2018-12-10 18:45:06 263

原创 分离链接法的删除操作函数

6-23 分离链接法的删除操作函数 (20 分)试实现分离链接法的删除操作函数。函数接口定义:bool Delete( HashTable H, ElementType Key );其中HashTable是分离链接散列表,定义如下:typedef struct LNode *PtrToLNode;struct LNode { ElementType Data; Ptr...

2018-12-10 18:02:30 710

原创 整型关键字的散列映射

7-11 整型关键字的散列映射 (25 分)给定一系列整型关键字和素数P,用除留余数法定义的散列函数将关键字映射到长度为P的散列表中。用线性探测法解决冲突。输入格式:输入第一行首先给出两个正整数N(≤1000)和P(≥N的最小素数),分别为待插入的关键字总数、以及散列表的长度。第二行给出N个整型关键字。数字间以空格分隔。输出格式:在一行内输出每个整型关键字在散列表中的位置。数字...

2018-12-10 08:25:32 879

原创 Covering(4*n铺瓷砖)

Bob’s school has a big playground, boys and girls always play games here after school.To protect boys and girls from getting hurt when playing happily on the playground, rich boy Bob decided to cover...

2018-12-09 21:09:21 423

原创 小乐乐搭积木(铺瓷砖n*m)(暴搜)

链接:https://ac.nowcoder.com/acm/contest/301/B来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32768K,其他语言65536K64bit IO Format: %lld题目描述小乐乐想要给自己搭建一个积木城堡。积木城堡我们假设为nm的平面矩形。小乐乐现在手里有12,2*1两种地砖。小乐乐想知道自己有多少种组合方...

2018-12-09 00:57:35 345

原创 小乐乐和25(模拟?)

链接:https://ac.nowcoder.com/acm/contest/301/J来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32768K,其他语言65536K64bit IO Format: %lld题目描述小乐乐特别喜欢25这个数字,他想把所有的数字都变成25的倍数。现在小乐乐得到一个数字,想问问你最少用几次操作才可以把这个数字改造成25的倍数...

2018-12-08 23:49:49 138

空空如也

空空如也

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

TA关注的人

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