解题报告
文章平均质量分 79
MrQ_zh
这个作者很懒,什么都没留下…
展开
-
UVA 10976-Fractions Again?!
问题:给你一个数k,求所有使得1/k = 1/x + 1/y成立的x≥y的整数对。分析:直接枚举...根据观察看出y是从k+1到2k,减小枚举范围。注意:一开始用的两次循环做的超时了...然后改用了复杂度更小的方法就AC了。#include#define max 100005int main(){ int num; while(scanf("%d",&num) != EOF原创 2016-11-15 23:11:06 · 283 阅读 · 0 评论 -
POJ 2036 Wireless Network
An 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 attacked, all computers in the n原创 2016-12-04 17:46:59 · 288 阅读 · 0 评论 -
POJ-1703并查集应用
The police office in Tadu City decides to say ends to the chaos, as launch actions to root up the TWO gangs in the city, Gang Dragon and Gang Snake. However, the police first needs to identify which g原创 2016-12-08 10:05:52 · 362 阅读 · 0 评论 -
POJ-2386 Lake Counting
Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <= 100; 1 <= M <= 100) squares. Each square contains either water (原创 2016-12-15 23:50:39 · 409 阅读 · 0 评论 -
POJ-1321 棋盘问题(DFS)
在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。Input输入含有多组测试数据。 每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,以及摆放棋子的数目。 n 当为-1 -1时表示输入结束原创 2016-12-17 20:06:09 · 603 阅读 · 0 评论 -
POJ-3278 Catch the cow(BFS)
Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a pointN (0 ≤ N ≤ 100,000) on a number line and the cow is at a point K (0 ≤ K ≤ 10原创 2016-12-21 16:55:11 · 403 阅读 · 0 评论 -
POJ1363 Rails && c++ stack容器简单使用
stack容器介绍:stack(堆栈)是一个容器的改编,它实现了一个先进后出的数据结构(FILO)使用该容器时需要包含#include头文件;定义stack对象的示例代码如下:stacks1;stacks2;stack的基本操作有:1.入栈:如s.push(x);2.出栈:如 s.pop().注意:出栈操作只是删除栈顶的元素,并不返回该元素。3.访问栈顶:如s.to转载 2016-11-25 22:35:20 · 1172 阅读 · 0 评论 -
1350. Canteen Timus Online Judge
问题:主要是要能看懂题意...题很简单... 顺便感谢下群里大佬的翻译题目是这个意思每顿饭有M种食物,输入的前N种食物代表着可能包含的食物有哪些然后输入一个k,剩下有k+1个部分每部分代表着第i个学生吃了含有这些食物的饭就会中毒最后一行那个数是M第一个学生吃了之后没问题,求其他学生吃过后会不会中毒分析:其实只需要拿每个人的危险食物和第一个人的原创 2016-12-06 20:44:58 · 439 阅读 · 0 评论 -
HDU-2094 产生冠军
问题:有一群人,打乒乓球比赛,两两捉对撕杀,每两个人之间最多打一场比赛。球赛的规则如下:如果A打败了B,B又打败了C,而A与C之间没有进行过比赛,那么就认定,A一定能打败C。如果A打败了B,B又打败了C,而且,C又打败了A,那么A、B、C三者都不可能成为冠军。根据这个规则,无需循环较量,或许就能确定冠军。你的任务就是面对一群比赛选手,在经过了若干场撕杀之后,确定是否已经实际上产生了原创 2016-11-23 18:22:49 · 495 阅读 · 0 评论 -
POJ-2251 Dungeon Master(BFS)
You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one minute to move one unit north, south原创 2016-12-22 09:20:33 · 282 阅读 · 0 评论 -
HDU-2054 A==B?
Problem DescriptionGive you two numbers A and B, if A is equal to B, you should print "YES", or print "NO". Inputeach test case contains two numbers A and B. Outputfor each case, i原创 2016-12-23 18:08:50 · 320 阅读 · 0 评论 -
POJ-1854 Evil Straw Warts Live
A palindrome is a string of symbols that is equal to itself when reversed. Given an input string, not necessarily a palindrome, compute the number of swaps necessary to transform the string into a pal原创 2017-04-17 22:03:26 · 401 阅读 · 0 评论 -
HDU-2055(水题)
#include#includeusing namespace std;int main(){ int n;// freopen("2.txt","r",stdin); scanf("%d",&n); getchar(); while(n--){ char t; int t1; int sum=0; scanf("%c %d",&t,&t1); getchar(原创 2017-01-31 23:58:52 · 382 阅读 · 0 评论 -
HDU-2030 汉字统计(水题)
问题:如题方法:就一点。。。汉子的ascii码小于零,一个汉子占两个ascii码#includeint main(){ char t; int n; scanf("%d",&n); getchar(); while(n--){ int sum=0; while((t=getchar())!='\n'){ if(t<0){ sum++; } }原创 2017-01-31 23:38:04 · 326 阅读 · 0 评论 -
hdu-2075 A|B? (水题)
一开始以为是大数除法...先写了个简单的试试没想到过了...#includeint main(){ int n,a,b; scanf("%d",&n); while(n--){ scanf("%d %d",&a,&b); printf(a%b==0?"YES\n":"NO\n"); } return 0;}原创 2017-01-24 12:36:59 · 335 阅读 · 0 评论 -
POJ1241Oil Deposits(DFS)
The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides th原创 2016-12-31 21:19:29 · 318 阅读 · 0 评论 -
HDU_1495非常可乐(BFS)
大家一定觉的运动以后喝可乐是一件很惬意的事情,但是seeyou却不这么认为。因为每次当seeyou买了可乐以后,阿牛就要求和seeyou一起分享这一瓶可乐,而且一定要喝的和seeyou一样多。但seeyou的手中只有两个杯子,它们的容量分别是N 毫升和M 毫升 可乐的体积为S (S<101)毫升 (正好装满一瓶) ,它们三个之间可以相互倒可乐 (都是没有刻度的,且 S==N+M,101>S>0,N原创 2016-12-31 20:52:04 · 398 阅读 · 0 评论 -
POJ-3069 Saruman's Army (贪心)
Saruman the White must lead his army along a straight path from Isengard to Helm’s Deep. To keep track of his forces, Saruman distributes seeing stones, known as palantirs, among the troops. Each pala原创 2016-12-20 11:37:31 · 236 阅读 · 0 评论 -
POJ-3984迷宫问题(典型BFS找最短路径)
定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0,};它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线。 Input一个5原创 2016-12-26 20:45:59 · 2559 阅读 · 0 评论 -
HDU-2085 核反应堆
问题:某核反应堆有两类事件发生:高能质点碰击核子时,质点被吸收,放出3个高能质点和1个低能质点;低能质点碰击核子时,质点被吸收,放出2个高能质点和1个低能质点。假定开始的时候(0微秒)只有一个高能质点射入核反应堆,每一微秒引起一个事件发生(对于一个事件,当前存在的所有质点都会撞击核子),试确定n微秒时高能质点和低能质点的数目。分析:简单递推...#includeusing原创 2016-11-23 17:41:50 · 305 阅读 · 0 评论 -
HDU-2045 不容易系列之(3)—— LELE的RPG难题(动态规划)
问题:有排成一行的n个方格,用红(Red)、粉(Pink)、绿(Green)三色涂每个格子,每格涂一色,要求任何相邻的方格不能同色,且首尾两格也不同色.求全部的满足要求的涂法.分析:就是高中的排列组合问题...写了写数学方法好像是错的...毕竟数学渣...在纸上画出来了树状图看的...然后发现从第四项开始都和前面两项有关系然后就把前三项写出来进行递推...注意:开数组时用int范围小了原创 2016-11-23 14:37:46 · 352 阅读 · 0 评论 -
code-forces Theatre Square
DescriptionTheatre Square in the capital city of Berland has a rectangular shape with the sizen × m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square w原创 2016-11-19 19:01:34 · 264 阅读 · 0 评论 -
UVA-1583 Digit Generator
问题:将一个数N(0分析:只要想通即使是最大位数和也只是9x5就好做了...遍历N-45到N就行;#includeint main(){ int q; scanf("%d",&q); while(q--){ int n,num,chu=10,sum=0; int flag=0; scanf("%d",&n); for(int i=n-45;i<n;i++){ s原创 2016-11-15 19:22:01 · 216 阅读 · 0 评论 -
HDU-2073 无限的路
甜甜从小就喜欢画图画,最近他买了一支智能画笔,由于刚刚接触,所以甜甜只会用它来画直线,于是他就在平面直角坐标系中画出如下的图形:甜甜的好朋友蜜蜜发现上面的图还是有点规则的,于是他问甜甜:在你画的图中,我给你两个点,请你算一算连接两点的折线长度(即沿折线走的路线长度)吧。 Input第一个数是正整数N(≤100)。代表数据的组数。每组数据由四个非负整数组成x1原创 2016-11-30 21:46:06 · 366 阅读 · 0 评论 -
HDU 2018 母牛的故事(简单动态规划)
问题:有一头母牛,它每年年初生一头小母牛。每头小母牛从第四个年头开始,每年年初也生一头小母牛。请编程实现在第n年的时候,共有多少头母牛?分析:1.今年总的牛数目等于去年+呢些去年三岁的今年可以生的->sum[now]=sum[now-1]+sum[now-3] 2.用递归实现......(也可以直接算出来每年的牛数...然后要哪年给哪年...)#include原创 2016-11-17 20:16:30 · 320 阅读 · 0 评论 -
UVA_Circular Sequence
问题:环形字符串从中间切开,找最小字典序;分析:暴力求解,把字符串不断向后移位产生新的字符串然后比较,用到strcmp比较字典序,strcpy复制字符串#include#includeint main(){ int q; scanf("%d",&q); while(q--){ char a[101],amin[101],c; scanf("%s",&a); int原创 2016-11-13 12:48:50 · 297 阅读 · 0 评论 -
UVA-455 Periodic Strings
问题:求周期字符串最小周期分析:枚举暴力求解,本来想用数学方法的感觉有点麻烦了,思路就是将字符串用1-strlen来整除,然后从上个周期的末尾开始比较,有不同则为不对。如果一直比较完都相等则为最小周期,最后的换行是按题目要求来的。#include#includeint main(){ int q; scanf("%d",&q); while(q--)原创 2016-11-13 10:50:25 · 292 阅读 · 0 评论 -
UVA-1225 Digit Counting 拆数计数
问题:Digit Counting 数数字 把前 n(n分析:关键就是拆分计数...就这一点难点...#includeint main(){ int q; scanf("%d",&q); while(q--){ int n,num,t=0,a[10]={0}; scanf("%d",&n); for(int i=1;i<=n;i++){ num=i;原创 2016-11-16 15:36:00 · 412 阅读 · 0 评论 -
POJ 2259 Team Queue
Team QueueDescriptionQueues and Priority Queues are data structures which are known to原创 2016-11-29 00:41:37 · 261 阅读 · 0 评论 -
HDU-2097 Sky数
Sky数Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 21700 Accepted Submission(s): 12329Problem DescriptionSky从小喜欢奇特的东西,而且天生对数字特别敏原创 2016-12-01 21:24:57 · 316 阅读 · 0 评论 -
HDU-2095 find your present (2)
find your present (2)Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 22091 Accepted Submission(s): 8734Problem DescriptionIn the原创 2016-12-01 22:27:53 · 250 阅读 · 0 评论 -
HDU-2042 不容易系列之二(递归)
问题:就是老汉去卖羊路上有检查站...过个检查站收了一半羊后换了老汉一只...老汉最后只有3只羊,知道检查站数量情况下求老汉一开始有多少羊?分析:毫无疑问简单递归实现...#includeusing namespace std;int solve(int n){ if(n==0) return 3; else return (solve(--n)-1)*2;}int main原创 2016-11-23 13:37:36 · 667 阅读 · 0 评论 -
HDU-2037 活动安排(贪心法...)
问题:简单来说就是有个节目表有起始时间和结束时间...要你在一天内尽可能多的完整看节目...分析:典型贪心法解...这次贪得是结束时间...意思就是让这一天中剩下的时间尽可能多...所以让结束时间尽可能的早剩下就是些判断起始时间是否比看完上个节目晚就行了...用这道题练了练排序函数、结构体使用...写的比较繁琐...见谅。原创 2016-11-23 01:09:33 · 362 阅读 · 0 评论 -
codeforces 285C Building Permutation (简单贪心)
Building Permutationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPermutationp is an ordered set of integers p1,原创 2016-11-22 11:17:27 · 520 阅读 · 0 评论 -
codeforces-75A Life Without zeros
Life Without Zerostime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputCan you imagine our life if we removed all zeros fro原创 2016-11-21 22:46:33 · 489 阅读 · 0 评论 -
UVA 156 map容器使用
Most crossword puzzle fans are used to anagrams--groups of words with the same letters in different orders--for example OPTS, SPOT, STOP, POTS and POST. Some words however do not have this attribute,原创 2016-12-04 15:39:51 · 258 阅读 · 0 评论 -
UVA 10815 Andy's First Dictionary
Andy's First DictionaryAndy, 8, has a dream - he wants to produce his very own dictionary. This is not an easy task for him, as the number of words that he knows is, well, not quite enough. Instea原创 2016-12-03 14:55:46 · 297 阅读 · 0 评论 -
code forces 732B The Best Friend Of a Man(超简单DP)
Recently a dog was bought for Polycarp. The dog's name is Cormen. Now Polycarp has a lot of troubles. For example, Cormen likes going for a walk.Empirically Polycarp learned that the dog needs at原创 2016-11-21 10:54:03 · 271 阅读 · 0 评论 -
code Forces 158A Next Round
"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest原创 2016-11-19 22:03:53 · 372 阅读 · 0 评论 -
POJ-1017 Packets
A factory produces products packed in square packets of the same height h and of the sizes 1*1, 2*2, 3*3, 4*4, 5*5, 6*6. These products are always delivered to customers in the square parcels of the s原创 2017-04-17 22:10:54 · 292 阅读 · 0 评论