自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 牛客小白月赛30题解

A 黑白边有n个点,m条边,每条边都分为黑边和白边,现在要选一些边,使得所有点都可以相互连通,要求用白边的条数最少。看到所有的点都相互连通,就可以想到生成树,所以把所有的白边和黑边分类,先用黑色的边构造生成树,再用白色的,这样就可以使所用的白色的边最少。#include <cstdio>#include <cstring>#include <cmath>#include <cstdlib>#include <queue>#inclu

2020-12-11 16:58:24 533

原创 HDU - 5950 Recursive sequence(矩阵快速幂)

Recursive sequenceFarmer John likes to play mathematics games with his N cows. Recently, they are attracted by recursive sequences. In each turn, the cows would stand in a line, while John writes two positive numbers a and b on a blackboard. And then, the

2020-12-04 16:16:57 139

原创 HDU - 6030 Happy Necklace(矩阵快速幂)

Happy NecklaceLittle Q wants to buy a necklace for his girlfriend. Necklaces are single strings composed of multiple red and blue beads.Little Q desperately wants to impress his girlfriend, he knows that she will like the necklace only if for every prime

2020-12-04 15:47:33 130

原创 HDU - 1005 Number Sequence(矩阵快速幂)

Number SequenceA number sequence is defined as follows:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7.Given A, B, and n, you are to calculate the value of f(n).InputThe input consists of multiple test cases. Each test case contains 3 i

2020-12-04 10:49:13 142

原创 AtCoder - abc183_c Travel(全排列)

题目链接:https://vjudge.net/problem/AtCoder-abc183_c题目大意:有N个城市,给出了这N个城市相互之间到达的时间,需要求从城市1开始,经过所有城市一次,最后回到城市1,所需的时间总和为K的路线数量。思路:因为有N个城市,而且每个城市只能经过一次,所以所有路线其实就是2-N的全排列(因为城市1是起点),最后再让排列以后的最后一个城市回到城市1就可以了。代码:#include <cstdio>#include <cstring>#inc

2020-11-17 17:05:44 254

原创 Elementary Math Gym - 101485E(二分图匹配)

Elementary MathEllen is teaching elementary math to her students and the time for the final exam has come. The exam consists of n questions. In each question the students have to add (+), subtract (−) or multiply (∗) a pair of numbers. Ellen has already c

2020-11-07 11:01:46 133

原创 Bridges Gym - 100712H(缩点 边双连通分量)

BridgesAn edge in an undirected graph is a bridgeif after removing it the graph will be disconnected.Given an undirected connected graph, you are allowed to add one edge between any pair of nodes so that thetotal number of bridges in the graph is minimi

2020-11-07 10:39:32 155

原创 Defuse the Bombs(简单二分)

The terrorists have planted some bombs in a building! Our hero, Little Horse, decides to rescue the people in the building. Unfortunately, there is more than one bomb, and Little Horse is unable to defuse all of them. To strive for more time for other peop

2020-11-02 13:46:09 1015

原创 POJ - 2407 Relatives(欧拉函数)

Given n, a positive integer, how many positive integers less than n are relatively prime to n? Two integers a and b are relatively prime if there are no integers x > 1, y > 0, z > 0 such that...

2020-04-28 15:23:01 116

原创 POJ - 2356 Find a multiple(鸽巢原理/抽屉原理)

The input contains N natural (i.e. positive integer) numbers ( N <= 10000 ). Each of that numbers is not greater than 15000. This numbers are not necessarily different (so it may happen that two or...

2020-04-28 11:41:53 150

原创 UVA - 11827 Maximum GCD(输入技巧+GCD暴力)

Given the N integers, you have to find the maximum GCD (greatest common divisor) of every possiblepair of these integers.InputThe first line of input is an integer N (1 < N < 100) that determ...

2020-04-15 15:31:38 218

原创 POJ - 2299 Ultra-QuickSort (树状数组)

In this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping two adjacent sequence elements until the sequence is sorted i...

2020-04-15 15:21:19 160

原创 HihoCoder - 1055 刷油漆(树形dp 背包)

描述上回说到,小Ho有着一棵灰常好玩的树玩具!这棵树玩具是由N个小球和N-1根木棍拼凑而成,这N个小球都被小Ho标上了不同的数字,并且这些数字都是处于1…N的范围之内,每根木棍都连接着两个不同的小球,并且保证任意两个小球间都不存在两条不同的路径可以互相到达。没错,这次说的还是这棵树玩具的故事!小Ho的树玩具的质量似乎不是很好,短短玩了几个星期,便掉漆了!“简直是一场噩梦!”小Ho拿着树玩具眼...

2020-04-09 11:59:24 149

原创 天梯赛 L1-046 整除光棍(除法原理)

这里所谓的“光棍”,并不是指单身汪啦~ 说的是全部由1组成的数字,比如1、11、111、1111等。传说任何一个光棍都能被一个不以5结尾的奇数整除。比如,111111就可以被13整除。 现在,你的程序要读入一个整数x,这个整数一定是奇数并且不以5结尾。然后,经过计算,输出两个数字:第一个数字s,表示x乘以s是一个光棍,第二个数字n是这个光棍的位数。这样的解当然不是唯一的,题目要求你输出最小的解。...

2020-03-12 14:24:18 586

原创 CodeForces - 731C Socks(贪心+并查集+STL)

Arseniy is already grown-up and independent. His mother decided to leave him alone for m days and left on a vacation. She have prepared a lot of food, left some money and washed all Arseniy’s clothes....

2020-01-10 17:07:56 554

原创 Cube Stacking

原题链接:http://poj.org/problem?id=1988题意:给定N个方块,排成一行,将它们编号1到N。再给出P个操作:①M i j表示将i所在的那一堆移到j所在那一堆的顶上。②C i表示一个询问,询问i下面有多少个方块。思路:带权并查集,一堆中最顶上的方块作为父节点,用dis[X] 统计X到父亲节点的距离,num[fa[X]]表示这个集合的大小,两者相减即为答案。标...

2020-01-09 19:17:50 94

原创 POJ - 1751 Highways(最小生成树记录路径)

HighwaysDescriptionThe island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has a very poor system of public highways. The Flatopian government is aware of this problem and has alrea...

2020-01-09 09:24:08 165

原创 POJ - 1679 The Unique MST(判断最小生成树是否唯一,次小生成树)

The Unique MSTGiven a connected undirected graph, tell if its minimum spanning tree is unique.Definition 1 (Spanning Tree): Consider a connected, undirected graph G = (V, E). A spanning tree of G is...

2020-01-09 09:12:09 189

原创 POJ - 1789 Truck History

Truck HistoryAdvanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery, other for furniture, or for bricks. The company has its own code describing eac...

2020-01-08 11:06:16 176

原创 POJ - 2031 Building a Space Station (三维最小生成树)

Building a Space StationDescriptionYou are a member of the space station engineering team, and are assigned a task in the construction process of the station. You are expected to write a computer pr...

2020-01-08 10:26:53 172

原创 牛客2019跨年AK场 E 【大】约数 (两个数的全部公约数)

链接:https://ac.nowcoder.com/acm/contest/3800/E题目描述Actci上课睡了一觉,下课屁颠屁颠的去找数学老师补课,问了老师一个题目:给出两个数a,b,问a和b的全部公约数是什么?数学老师一看这道题太简单了,不屑回答,于是就交给了你。输入描述:一行两个数a,b.输出描述:a和b的全部公约数,每个数字之间空格隔开。示例1输入25 37输出...

2020-01-08 08:42:39 227

原创 Newcoder 被3整除的子序列 (dp)

链接:https://ac.nowcoder.com/acm/problem/21302题目描述给你一个长度为50的数字串,问你有多少个子序列构成的数字可以被3整除答案对1e9+7取模输入描述:输入一个字符串,由数字构成,长度小于等于50输出描述:输出一个整数示例1输入132输出3示例2输入9输出1示例3输入333输出7示例4输入123456输出...

2020-01-07 09:24:10 189

原创 哈理工"歌尔创客杯"新生赛 F 当会长和一群手贱的耗子在电梯相遇(找因子)

链接:https://ac.nowcoder.com/acm/contest/3474/F来源:牛客网题目描述有一群耗纸,它们喜欢在ACM协会的集训楼的电梯里反复玩弄电梯(假定有这栋楼。。。),这些耗纸定义了一种规则,当他们从一楼涌进电梯之后,每只耗纸都会在电梯上啪啪啪,到处乱拍,第i只耗纸,把楼层是i的倍数全都按了一遍,也就是说第13只耗纸会把第13,26,39等楼全部按一遍,假设这个电梯...

2019-12-23 08:35:46 357

原创 HDU - 2639 Bone Collector II(01背包的第K优解)

Bone Collector IIProblem DescriptionThe title of this problem is familiar,isn’t it?yeah,if you had took part in the “Rookie Cup” competition,you must have seem this title.If you haven’t seen it befo...

2019-12-21 11:05:50 123

原创 HDU - 1233 还是畅通工程(最小生成树入门)

还是畅通工程Problem Description某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离。省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可),并要求铺设的公路总长度为最小。请计算最小的公路总长度。Input测试输入包含若干测试用例。每个测试用例的第1行给出村庄数目N ( < 100 );随后的...

2019-12-18 16:08:14 390

原创 "新生赛"长沙理工大学程序设计竞赛(重现赛)C 7-教417

题目链接:https://ac.nowcoder.com/acm/contest/3530/C题目描述咚咚咚!在安静的7教417夜晚,车神带来了一堆神秘的数字。而417的小伙伴都只钟爱于包含4和7的数字。例如数字:747,4,7747,4,7是他们钟爱的数字,而476,5,27476,5,27不是。车神灵机一动,突然问:对于给定的数字n,能否找出各个数位上数字和为n的最小钟爱数字。如果...

2019-12-16 11:10:21 206

原创 POJ-2492 A Bug's Life(二分图染色 或者 种类并查集)

A Bug’s LifeDescriptionBackgroundProfessor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two different genders and that they only interact with b...

2019-12-10 20:03:13 125

原创 太原理工大学第二届程序设计新生赛预赛 D Imperishable Night(前缀和思想)

题目链接:https://ac.nowcoder.com/acm/problem/200041、Imperishable Night链接:https://ac.nowcoder.com/acm/problem/200041来源:牛客网链接:https://ac.nowcoder.com/acm/problem/200041来源:牛客网在地图的帮助下,Vanis在那个夜晚 (the sp...

2019-12-09 13:36:05 150

原创 POJ - 1456 Supermarket(贪心+并查集优化)

SupermarketDescriptionA supermarket has a set Prod of products on sale. It earns a profit px for each product x∈Prod sold by a deadline dx that is measured as an integral number of time units starti...

2019-12-07 10:40:34 168

原创 HDU - 3038 How Many Answers Are Wrong(带权并查集+路径压缩)

How Many Answers Are WrongProblem DescriptionTT and FF are … friends. Uh… very very good friends -________-bFF is a bad boy, he is always wooing TT to play the following game with him. This is a ve...

2019-12-07 09:51:04 145

原创 POJ - 1611 The Suspects(并查集)

The SuspectsDescriptionSevere acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. To minimize transmission to others, ...

2019-12-06 19:59:56 59

原创 POJ- 2236 Wireless Network(并查集入门)

Wireless NetworkDescriptionAn earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, but an unexpected aftershock att...

2019-12-06 19:29:11 80

原创 POJ - 1905 Expanding Rods(几何+二分)

Expanding RodsDescriptionWhen a thin rod of length L is heated n degrees, it expands to a new length L’=(1+n*C)*L, where C is the coefficient of heat expansion.When a thin rod is mounted on two so...

2019-12-05 11:19:05 148

原创 HDU-2199 Can you solve this equation?(二分)

Can you solve this equation?Problem DescriptionNow,given the equation 8x^4 + 7x^3 + 2x^2 + 3x + 6 == Y,can you find its solution between 0 and 100;Now please try your lucky.InputThe first line of...

2019-12-05 10:50:10 103

原创 POJ - 3320 Jessica's Reading Problem(尺取+map)

A - Jessica’s Reading ProblemJessica’s a very lovely girl wooed by lots of boys. Recently she has a problem. The final exam is coming, yet she has spent little time on it. If she wants to pass it, sh...

2019-12-04 16:50:28 119

原创 HDU 1241 Oil Deposits(简单dfs)

Oil DepositsProblem DescriptionThe GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, a...

2019-11-29 16:14:38 65

原创 POJ - 2289 Jamie's Contact Groups(二分+二分图多重匹配)

Jamie’s Contact GroupsJamie is a very popular girl and has quite a lot of friends, so she always keeps a very long contact list in her cell phone. The contact list has become so long that it often ta...

2019-11-26 19:34:14 1497

原创 POJ - 2594 Treasure Exploration(最小路径覆盖+floyd)

Treasure ExplorationHave you ever read any book about treasure exploration? Have you ever see any film about treasure exploration? Have you ever explored treasure? If you never have such experiences,...

2019-11-22 19:53:30 108

原创 HDU - 1054 Strategic Game(最小点覆盖)

Strategic GameBob enjoys playing computer games, especially strategic games, but sometimes he cannot find the solution fast enough and then he is very sad. Now he has the following problem. He must d...

2019-11-22 19:20:07 119

原创 POJ - 3020 Antenna Placement(最小路径覆盖+二分图最大匹配)

The Global Aerial Research Centre has been allotted the task of building the fifth generation of mobile phone nets in Sweden. The most striking reason why they got the job, is their discovery of a new...

2019-11-22 18:59:52 110

空空如也

空空如也

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

TA关注的人

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