摘要: 题目大意:有一只蜗牛,在一个深为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(" 阅读全文
posted @ 2013-04-29 23:57 xiaxiaosheng 阅读(185) 评论(0) 推荐(0) 编辑
摘要: 解题报告:本题就是用数组模拟大数的相加,输入的第一行是一个n,表示有n组测试数据,输入有多个大数,输入以0结尾。用数组模拟加法就可以了,编写一个add(char *)函数,没输入一次都将对应的位置的值加到和里面去,保存结果的数组应该定义一个int型的数组。而且数组的第一位应该保存呢结果的最高位,这样就可以方便地进行进位,只是记得在输出的时候要倒过来输就可以了。还有一个要注意的是,本题的格式比较坑,表示交了十多次都PE,因为看了disscuss里面一位同学错误的格式,晕,格式只要在输出结果的后面空一行就可以了,但测试数据的最后一组后面不要空行、View Code 1 #include<st 阅读全文
posted @ 2013-04-29 23:36 xiaxiaosheng 阅读(155) 评论(0) 推荐(0) 编辑
摘要: Problem Description上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房间A和B,那么既可以通过它从房间A走到房间B,也可以通过它从... 阅读全文
posted @ 2013-04-28 23:55 xiaxiaosheng 阅读(157) 评论(0) 推荐(0) 编辑
摘要: Problem Description某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路?Input测试输入包含若干测试用例... 阅读全文
posted @ 2013-04-28 21:01 xiaxiaosheng 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 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 ... 阅读全文
posted @ 2013-04-26 21:21 xiaxiaosheng 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2013-04-25 21:40 xiaxiaosheng 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2013-04-24 21:56 xiaxiaosheng 阅读(91) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2013-04-24 21:37 xiaxiaosheng 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2013-04-22 21:42 xiaxiaosheng 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2013-04-20 21:30 xiaxiaosheng 阅读(175) 评论(0) 推荐(0) 编辑