04 2013 档案
摘要:题意描述:给定两个点的坐标,求两个点在笛卡尔坐标系上的距离,输入有多组测试数据。解题报告:这题要注意的地方就是不要把数据定义成int型去了。然后用一句sort((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));就可以了。View Code 1 #include<stdio.h>2 #include<math.h>3 double x3,y3,x2,y2;4 int main() {5 while(scanf("%lf%lf%lf%lf",&x2,&y2,&x3,&y3)!=EOF)6 printf(&q
阅读全文
摘要:题目大意:有一只蜗牛,在一个深为n英尺的井里,它每分钟可以向上爬行u英尺,但是怕一分钟就必须休息一分钟,在休息的这一分钟内,它将会下滑d 的距离,输入有多组数据,每行输入三个数n u d,输入以一个0结束。解题思路:直接一分钟一分钟地加就可以了,保存它已经上爬的距离,然后没分钟更新一次,并且每分钟都要更新一次,判断它是否已经爬到了井口。View Code 1 #include<stdio.h> 2 int main(){ 3 int n,u,d; 4 while(scanf("%d",&n)&&n!=0) { 5 scanf("
阅读全文
摘要:解题报告:本题就是用数组模拟大数的相加,输入的第一行是一个n,表示有n组测试数据,输入有多个大数,输入以0结尾。用数组模拟加法就可以了,编写一个add(char *)函数,没输入一次都将对应的位置的值加到和里面去,保存结果的数组应该定义一个int型的数组。而且数组的第一位应该保存呢结果的最高位,这样就可以方便地进行进位,只是记得在输出的时候要倒过来输就可以了。还有一个要注意的是,本题的格式比较坑,表示交了十多次都PE,因为看了disscuss里面一位同学错误的格式,晕,格式只要在输出结果的后面空一行就可以了,但测试数据的最后一组后面不要空行、View Code 1 #include<st
阅读全文
摘要:Problem Description上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房间A和B,那么既可以通过它从房间A走到房间B,也可以通过它从...
阅读全文
摘要:Problem Description某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路?Input测试输入包含若干测试用例...
阅读全文
摘要:View Code 1 #include<cstdio> 2 #include<string.h> 3 char S[1005],T[1005]; 4 int BF(char *s,char *t) { 5 int i=0,j=0,sum=0; 6 int len1=strlen(s); 7 int len2=strlen(t); 8 while(i<len1) { 9 if(s[i]==t[j]) {10 if(j==len2-1) {11 sum++;12 ...
阅读全文
摘要:Problem DescriptionGiven a string containing only 'A' - 'Z', we could encode it using the following method: 1. Each sub-string containing k same characters should be encoded to "kX" where "X" is the only character in this sub-string.2. If the length of the sub-str
阅读全文
摘要:Problem DescriptionA simple mathematical formula for e iswhere n is allowed to go to infinity. This can actually yield very accurate approximations of e using relatively small values of n.OutputOutput the approximations of e generated by the above formula for the values of n from 0 to 9. The begi...
阅读全文
摘要:Problem DescriptionThe 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 specified order. It costs 6 seconds to move the elevator up one floor, and 4 seconds to move down one floor. The
阅读全文
摘要:DescriptionAndrew is working as system administrator and is planning to establish a new network in his company. There will be N hubs in the company, t...
阅读全文
摘要:Problem DescriptionIn the planet w-503 of galaxy cgb, there is a kind of intelligent creature named QS. QScommunicate with each other via networks. If...
阅读全文
摘要:DescriptionThere are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can connect to each othe...
阅读全文
摘要:Problem DescriptionThe Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra roads between vil...
阅读全文
摘要:Problem DescriptionHey, welcome to HDOJ(Hangzhou Dianzi University Online Judge).In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.InputThe input will consist of a series of integers n, one integer per line.OutputFor each case, output SUM(n) in one line, followed by a blank ...
阅读全文
摘要:Problem Description输入一个字符串,判断其是否是C的合法标识符。Input输入数据包含多个测试实例,数据的第一行是一个整数n,表示测试实例的个数,然后是n行输入数据,每行是一个长度不超过50的字符串。Output对于每组输入数据,输出一行。如果输入数据是C的合法标识符,则输出"yes",否则,输出“no”。Sample Input3 12ajf fi8x_a ff ai_2Sample Outputno yes noAC代码:#include<stdio.h>#include<string.h>void main(){ int n=
阅读全文
摘要:Problem Description输入一行数字,如果我们把这行数字中的‘5’都看成空格,那么就得到一行用空格分割的若干非负整数(可能有些整数以‘0’开头,这些头部的‘0’应该被忽略掉,除非这个整数就是由若干个‘0’组成的,这时这个整数就是0)。你的任务是:对这些分割得到的整数,依从小到大的顺序排序输出。Input输入包含多组测试用例,每组输入数据只有一行数字(数字之间没有空格),这行数字的长度不大于1000。 输入数据保证:分割得到的非负整数不会大于100000000;输入数据不可能全由‘5’组成。Output对于每个测试用例,输出分割得到的整数排序的结果,相邻的两个整数之间用一个空格分开
阅读全文
摘要:Problem Description求A^B的最后三位数表示的整数。 说明:A^B的含义是“A的B次方”Input输入数据包含多个测试实例,每个实例占一行,由两个正整数A和B组成(1<=A,B<=10000),如果A=0, B=0,则表示输入数据的结束,不做处理。Output对于每个测试实例,请输出A^B的最后三位表示的整数,每个输出占一行。Sample Input2 3 12 6 6789 10000 0 0Sample Output8 984 1AC代码:#include<stdio.h> int A,B; int main() { while(scanf(&qu
阅读全文
摘要:Problem DescriptionACboy has N courses this term, and he plans to spend at most M days on study.Of course,the profit he will gain from different course depending on the days he spend on it.How to arrange the M days for the N courses to maximize the profit?InputThe input consists of multiple data set
阅读全文
摘要:Problem Description把一个字符三角形掏空,就能节省材料成本,减轻重量,但关键是为了追求另一种视觉效果。在设计的过程中,需要给出各种花纹的材料和大小尺寸的三角形样板,通过电脑临时做出来,以便看看效果。Input每行包含一个字符和一个整数n(0<n<41),不同的字符表示不同的花纹,整数n表示等腰三角形的高。显然其底边长为2n-1。如果遇到@字符,则表示所做出来的样板三角形已经够了。Output每个样板三角形之间应空上一行,三角形的中间为空。显然行末没有多余的空格。Sample InputX 2 A 7 @Sample OutputX XXX A A A A A A
阅读全文
摘要:Problem DescriptionGive you the width and height of the rectangle,darw it.InputInput contains a number of test cases.For each case ,there are two numbers n and m (0 < n,m < 75)indicate the width and height of the rectangle.Iuput ends of EOF.OutputFor each case,you should draw a rectangle with
阅读全文
摘要:Problem DescriptionThere are some students in a class, Can you help teacher find the highest student .InputThere are some cases. The first line contains an integer t, indicate the cases; Each case have an integer n ( 1 ≤ n ≤ 100 ) , followed n students’ height.OutputFor each case output the highest
阅读全文
摘要:Problem Descriptionpotato老师虽然很喜欢教书,但是迫于生活压力,不得不想办法在业余时间挣点外快以养家糊口。 “做什么比较挣钱呢?筛沙子没力气,看大门又不够帅...”potato老师很是无奈。 “张艺谋比你还难看,现在多有钱呀,听说还要导演奥运开幕式呢!你为什么不去娱乐圈发展呢?”lwg在一旁出主意。 嗯,也是,为了生存,就委屈点到娱乐圈混混吧,马上就拍一部激光电影《杭电记忆——回来我的爱》。 说干就干,马上海选女主角(和老谋子学的,此举可以吸引媒体的眼球,呵呵),并且特别规定,演员必须具有ac的基本功,否则直接out! 由于策划师风之鱼(大师级水王)宣传到位,来应聘的M
阅读全文
摘要:Problem Description“回文串”是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。请写一个程序判断读入的字符串是否是“回文”。Input输入包含多个测试实例,输入数据的第一行是一个正整数n,表示测试实例的个数,后面紧跟着是n个字符串。Output如果一个字符串是回文串,则输出"yes",否则输出"no".Sample Input4 level abcde noon hahaSample Outputyes no yes noAC代码:#include<stdio.h>#include<st
阅读全文
摘要:Problem Description作为杭电的老师,最盼望的日子就是每月的8号了,因为这一天是发工资的日子,养家糊口就靠它了,呵呵 但是对于学校财务处的工作人员来说,这一天则是很忙碌的一天,财务处的小胡老师最近就在考虑一个问题:如果每个老师的工资额都知道,最少需要准备多少张人民币,才能在给每位老师发工资的时候都不用老师找零呢? 这里假设老师的工资都是正整数,单位元,人民币一共有100元、50元、10元、5元、2元和1元六种。Input输入数据包含多个测试实例,每个测试实例的第一行是一个整数n(n<100),表示老师的人数,然后是n个老师的工资。 n=0表示输入的结束,不做处理。Outp
阅读全文

浙公网安备 33010602011771号