自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 sort函数和qsort函数的用法

sort函数是c++库里面自带的用法如下:#include<iostream>#include<algorithm>#include<queue>#include<stdio.h>#include<string.h>#include <stack>#include<math.h>using namespace std;bool cmp(int a,int b)//自己定义是从大大小{ return

2021-07-08 18:00:51 185

原创 求大佬改正啊!!HDU1254到底哪里错了啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊

推箱子Problem Description推箱子是一个很经典的游戏.今天我们来玩一个简单版本.在一个M*N的房间里有一个箱子和一个搬运工,搬运工的工作就是把箱子推到指定的位置,注意,搬运工只能推箱子而不能拉箱子,因此如果箱子被推到一个角上(如图2)那么箱子就不能再被移动了,如果箱子被推到一面墙上,那么箱子只能沿着墙移动.现在给定房间的结构,箱子的位置,搬运工的位置和箱子要被推去的位置,请你计算出搬运工至少要推动箱子多少格.Input输入数据的第一行是一个整数T(1<=T<=20

2021-06-05 14:24:14 176 1

原创 2021-05-30

A simple problemProblem DescriptionZty很痴迷数学问题.。一天,yifenfei出了个数学题想难倒他,让他回答1 / n。但Zty却回答不了_. 请大家编程帮助他.Input第一行整数T,表示测试组数。后面T行,每行一个整数 n (1<=|n|<=10^5).Output输出1/n. (是循环小数的,只输出第一个循环节).Sample Input4237168Sample Output0.50.30.14285

2021-05-30 21:27:44 154

原创 HDU1236排名 (结构体排序,sort)

排名Problem Description今天的上机考试虽然有实时的Ranklist,但上面的排名只是根据完成的题数排序,没有考虑每题的分值,所以并不是最后的排名。给定录取分数线,请你写程序找出最后通过分数线的考生,并将他们的成绩按降序打印。Input测试输入包含若干场考试的信息。每场考试信息的第1行给出考生人数N ( 0 < N< 1000 )、考题数M ( 0 < M < = 10 )、分数线(正整数)G;第2行排序给出第1题至第M题的正整数分值;以下N行,每

2021-05-29 17:28:28 150

原创 leedcode 2-两数相加(链表)

给你两个 非空 的链表,表示两个非负的整数。它们每位数字都是按照 逆序 的方式存储的,并且每个节点只能存储 一位 数字。请你将两个数相加,并以相同形式返回一个表示和的链表。你可以假设除了数字 0 之外,这两个数都不会以 0 开头。示例 1:输入:l1 = [2,4,3], l2 = [5,6,4]输出:[7,0,8]解释:342 + 465 = 807.示例 2:输入:l1 = [0], l2 = [0]输出:[0]示例 3:

2021-05-17 21:32:48 71

原创 简单计算器 简单栈的应用 经典

Problem Description读入一个只包含 +, -, *, / 的非负整数计算表达式,计算该表达式的值。Input测试输入包含若干测试用例,每个测试用例占一行,每行不超过200个字符,整数和运算符之间用一个空格分隔。没有非法表达式。当一行中只有0时输入结束,相应的结果不要输出。Output对每个测试用例输出1行,即该表达式的值,精确到小数点后2位。Sample Input1 + 24 + 2 * 5 - 7 / 110Sample Output3.001

2021-03-21 12:02:50 79

原创 Tian Ji -- The Horse Racing 贪心算法

Problem DescriptionHere is a famous story in Chinese history.“That was about 2300 years ago. General Tian Ji was a high official in the country Qi. He likes to play horse racing with the king and others.”“Both of Tian and the king have three horses in d

2021-03-18 18:18:01 214

原创 Tempter of the Bone DFS+奇偶减枝

Problem DescriptionThe doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to shake, and the doggie could feel the ground sinking. He realized that the bone was a trap, and he tried desperatel

2021-03-18 15:47:59 108

原创 三角形 三角形分区域 tr[x]=tr[x-1]+6*(x-1)

Problem Description用N个三角形最多可以把平面分成几个区域?Input输入数据的第一行是一个正整数T(1<=T<=10000),表示测试数据的数量.然后是T组测试数据,每组测试数据只包含一个正整数N(1<=N<=10000).Output对于每组测试数据,请输出题目中要求的结果.Sample Input212Sample Output28就是一公式:tr[x]=tr[x-1]+6*(x-1)#include<io

2021-03-15 10:44:21 179

原创 Max Sum 动态规划

Problem DescriptionGiven a sequence a[1],a[2],a[3]…a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 + 4 = 14.InputThe first line of the input contains an integer

2021-03-13 11:48:27 149

原创 Super Jumping! Jumping! Jumping! 最大递增序列和

Problem DescriptionNowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to you now.The game can be played by two or more than two pl

2021-03-13 11:32:12 233

原创 I NEED A OFFER! 求概率的背包问题

Problem DescriptionSpeakless很早就想出国,现在他已经考完了所有需要的考试,准备了所有要准备的材料,于是,便需要去申请学校了。要申请国外的任何大学,你都要交纳一定的申请费用,这可是很惊人的。Speakless没有多少钱,总共只攒了n万美元。他将在m个学校中选择若干的(当然要在他的经济承受范围内)。每个学校都有不同的申请费用a(万美元),并且Speakless估计了他得到这个学校offer的可能性b。不同学校之间是否得到offer不会互相影响。“I NEED A OFFER”,他

2021-03-13 10:47:43 131

原创 Bone Collector 01背包问题

Problem DescriptionMany years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to collect varies of bones , such as dog’s , cow’s , also he went to the grave …The bone collector had a big bag with a volume of V ,a

2021-03-13 10:04:21 101

原创 Number Sequence

Problem DescriptionA 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 conta

2021-03-12 20:59:04 83

原创 Big Number

Problem DescriptionIn many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, encryption, etc. In this problem you are given a number, you have to determine the number of digi

2021-03-12 18:27:35 86

原创 杭电oj 2031进制转换

进制转换Problem Description输入一个十进制数N,将它转换成R进制数输出。Input输入数据包含多个测试实例,每个测试实例包含两个整数N(32位整数)和R(2<=R<=16, R<>10)。Output为每个测试实例输出转换后的数,每个输出占一行。如果R大于10,则对应的数字规则参考16进制(比如,10用A表示,等等)。Sample Input7 223 12-4 3Sample Output1111B-11解题思路:

2021-03-10 21:07:33 152

原创 A + B Again 杭电oj 2056 十六进制

Problem DescriptionThere must be many A + B problems in our HDOJ , now a new one is coming.Give you two hexadecimal integers , your task is to calculate the sum of them,and print it in hexadecimal too.Easy ? AC it !InputThe input contains several t

2021-03-10 20:34:28 144

原创 杭电oj 2629 (截取字符串)

Identity CardProblem DescriptionDo you own an ID card?You must have a identity card number in your family’s Household Register. From the ID card you can get specific personal information of everyone. The number has 18 bits,the first 17 bits contain spec

2021-03-09 17:57:57 194

原创 杭电oj 1197进制问题

Specialized Four-Digit NumbersProblem DescriptionFind and list all four-digit numbers in decimal notation that have the property that the sum of its four digits equals the sum of its digits when represented in hexadecimal (base 16) notation and also equ

2021-03-09 17:04:03 302 1

原创 杭电 1170 水题

Balloon Comes!Problem DescriptionThe contest starts now! How excited it is to see balloons floating around. You, one of the best programmers in HDU, can get a very beautiful balloon if only you have solved the very very very… easy problem.Give you an o

2021-03-08 20:46:04 357

原创 杭电oj 2734 水题

QuicksumProblem DescriptionA checksum is an algorithm that scans a packet of data and returns a single number. The idea is that if the packet is changed, the checksum will also change, so checksums are often used for detecting transmission errors, valid

2021-03-08 19:44:40 296

原创 Sum of Factorials

Problem DescriptionJohn von Neumann, b. Dec. 28, 1903, d. Feb. 8, 1957, was a Hungarian-American mathematician who made important contributions to the foundations of mathematics, logic, quantum physics,meteorology, science, computers, and game theory. He

2021-02-07 15:16:34 148

原创 汉诺塔V

Problem Description用1,2,…,n表示n个盘子,称为1号盘,2号盘,…。号数大盘子就大。经典的汉诺塔问题经常作为一个递归的经典例题存在。可能有人并不知道汉诺塔问题的典故。汉诺塔来源于印度传说的一个故事,上帝创造世界时作了三根金刚石柱子,在一根柱子上从下往上按大小顺序摞着64片黄金圆盘。上帝命令婆罗门把圆盘从下面开始按大小顺序重新摆放在另一根柱子上。并且规定,在小圆盘上不能放大圆盘,在三根柱子之间一回只能移动一个圆盘。我们知道最少需要移动2^64-1次.在移动过程中发现,有的圆盘移动次

2021-02-05 20:04:25 152

原创 Bank Interest

Problem DescriptionFarmer John made a profit last year! He would like to invest it well but wonders how much money he will make. He knows the interest rate R (an integer between 0 and 20) that is compounded annually at his bank. He has an integer amount o

2021-01-23 22:24:12 118

原创 Sum

Problem DescriptionConsider the natural numbers from 1 to N. By associating to each number a sign (+ or -) and calculating the value of this expression we obtain a sum S. The problem is to determine for a given sum S the minimum number N for which we can

2021-01-23 22:02:38 113

原创 Factorial 求阶乘又多少个零(水)

Problem DescriptionThe most important part of a GSM network is so called Base Transceiver Station (BTS). These transceivers form the areas called cells (this term gave the name to the cellular phone) and every phone connects to the BTS with the strongest

2021-01-23 00:14:19 85

转载 套模板的DFS 最短路

最短路Problem Description在每年的校赛里,所有进入决赛的同学都会获得一件很漂亮的t-shirt。但是每当我们的工作人员把上百件的衣服从商店运回到赛场的时候,却是非常累的!所以现在他们想要寻找最短的从商店到赛场的路线,你可以帮助他们吗?Input输入包括多组数据。每组数据第一行是两个整数N、M(N<=100,M<=10000),N表示成都的大街上有几个路口,标号为1的路口是商店所在地,标号为N的路口是赛场所在地,M则表示在成都有几条路。N=M=0表示输入结束。接下来M行,

2021-01-22 01:22:04 135

原创 Error Correction

Problem DescriptionA boolean matrix has the parity property when each row and each column has an even sum, i.e. contains an even number of bits which are set. Here’s a 4 x 4 matrix which has the parity property:1 0 1 00 0 0 01 1 1 10 1 0 1The sums of

2021-01-21 00:43:29 276

原创 Stamps

BackgroundEverybody hates Raymond. He’s the largest stamp collector on planet earth and because of that he always makes fun of all the others at the stamp collector parties. Fortunately everybody loves Lucy, and she has a plan. She secretly asks her frien

2021-01-20 12:30:18 1208

原创 All in All 水题

Problem DescriptionYou have devised a new encryption technique which encodes a message by inserting between its characters randomly generated strings in a clever way. Because of pending patent issues we will not discuss in detail how the strings are gener

2021-01-20 11:37:28 94

原创 The Triangle

Problem Description73 88 1 02 7 4 44 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 route that starts at the top and ends somewhere on the base. Each step

2021-01-17 00:52:06 79

原创 IP Address

Problem DescriptionSuppose you are reading byte streams from any device, representing IP addresses. Your task is to convert a 32 characters long sequence of ‘1s’ and ‘0s’ (bits) to a dotted decimal format. A dotted decimal format for an IP address is for

2021-01-16 01:29:54 188

原创 No Brainer 超级水

InputThe first line contains a single integer n indicating the number of data sets. The following n lines each represent a data set. Each data set will be formatted according to the following description: A single data set consists of a line “X Y”, whe

2021-01-16 01:00:46 139

原创 Anniversary Cake

Problem DescriptionNahid Khaleh decides to invite the kids of the “Shahr-e Ghashang” to her wedding anniversary. She wants to prepare a square-shaped chocolate cake with known size. She asks each invited person to determine the size of the piece of cake

2021-01-15 14:26:33 130

原创 Financial Management

Problem DescriptionLarry graduated this year and finally has a job. He’s making a lot of money, but somehow never seems to have enough. Larry has decided that he needs to grab hold of his financial portfolio and solve his financing problems. The first st

2021-01-15 13:28:08 179

原创 汉字统计 HDU2030

Problem Description统计给定文本文件中汉字的个数。Input输入文件首先包含一个整数n,表示测试实例的个数,然后是n段文本。Output对于每一段文本,输出其中的汉字的个数,每个测试实例的输出占一行。[Hint:]从汉字机内码的特点考虑~Sample Input2WaHaHa! WaHaHa! 今年过节不说话要说只说普通话WaHaHa! WaHaHa!马上就要期末考试了Are you ready?Sample Output149Author

2021-01-14 23:49:33 115

原创 K - Rochambeau(POJ2912)

N children are playing Rochambeau (scissors-rock-cloth) game with you. One of them is the judge. The rest children are divided into three groups (it is possible that some group is empty). You don’t know who is the judge, or how the children are grouped. T.

2020-12-10 10:54:44 117

原创 J - A Bug‘s Life(加权并查集)

J - A Bug’s LifeBackgroundProfessor 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 bugs of the opposite gender. In his experiment, individual bugs

2020-12-10 10:18:48 138

原创 How Many Answers Are Wrong(HDU 3038 带权并查集判错)

How Many Answers Are WrongTT 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 very humdrum game. To begin with, TT should write down a sequence of integers

2020-12-08 19:28:25 139

原创 食物链

动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。有人用两种说法对这N个动物所构成的食物链关系进行描述:第一种说法是"1 X Y",表示X和Y是同类。第二种说法是"2 X Y",表示X吃Y。此人对N个动物,用上述两种说法,一句接一句地说出K句话,这K句话有的是真的,有的是假的。当一句话满足下列三条之一时,这句话就是假话,否则就是真话。1) 当前的话与前面的某些.

2020-12-06 16:42:41 207

空空如也

空空如也

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

TA关注的人

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