SDNUOJ刷题杂谈(—)小题大做

来源:互联网 发布:淘宝卖家贷款 编辑:程序博客网 时间:2024/05/17 23:47

天天刷题,慢慢的也会有一些感想。一般情况下我们会认为那些题目很多字,样例很大很多,代码很多行的题是难题。当然,这样的题一般不好做,但有时候我们也会在阴沟翻船,小坑摔倒。

就比如:

1094.Clock

Time Limit: 1000 MS    Memory Limit: 32768 KB
Total Submission(s): 102    Accepted Submission(s): 39

Description

There is an analog clock with two hands: an hour hand and a minute hand. The two hands form an angle. The angle is measured as the smallest angle between the two hands. The angle between the two hands has a measure that is greater than or equal to 0 and less than or equal to 180 degrees.
Given a sequence of five distinct times written in the format hh : mm , where hh are two digits representing full hours (00 <= hh <= 23) and mm are two digits representing minutes (00 <= mm <= 59) , you are to write a program that finds the median, that is, the third element of the sorted sequence of times in a nondecreasing order of their associated angles. Ties are broken in such a way that an earlier time precedes a later time.
For example, suppose you are given a sequence (06:05, 07:10, 03:00, 21:00, 12:55) of times. Because the sorted sequence is (12:55, 03:00, 21:00, 06:05, 07:10), you are to report 21:00.

Input

The input consists of T test cases. The number of test cases (T) is given on the first line of the input file. Each test case is given on a single line, which contains a sequence of five distinct times, where times are given in the format hh : mm and are separated by a single space.

Output

Print exactly one line for each test case. The line is to contain the median in the format hh : mm of the times given. The following shows sample input and output for three test cases.

Sample Input

300:00 01:00 02:00 03:00 04:0006:05 07:10 03:00 21:00 12:5511:05 12:05 13:05 14:05 15:05

Sample Output

02:0021:0014:05

Source

Asia 2003(Seoul)
这个题,其实思路很好找的,转换成分钟排个序喽。
然而,在真正实现的时候,我们可能会忘记他的角度始终在0到180之间,至极则反,取个绝对值啦;对于每个格式time算角度时,别忘了分针转的时候时针也在转,每分钟半度 etc. 这些可供粗心的方面固然重要,再加上做后的输出,也不好写。这种格式在 office里自然好弄,要是自己写的话你确定会弄吗。关于:printf ("%02d : %02d\n", a, b); 这种老司机的熟练手法,反正我是自己查了百度之后才get 到这个新技能的。事出毫末,也是不可不察啊。或许,一个合格程序员的打造过程,就是它不断吸收这些细节知识的路吧。
还有一个极好的反面样例供大家吸取教训,也为我自己默哀:
 

1072.我们爱递归

Time Limit: 1000 MS    Memory Limit: 32768 KB
Total Submission(s): 211    Accepted Submission(s): 65

Description

我们想明白递归函数到底是怎么运作的,所以想用递归来计算当给定一个正整数n(n < 16)时,求出n + (n-1)……+1的值,同时进行一些输出
要求写一个int plus1(int a)形式的函数,在进入递归函数时,输出相关信息。在调用结束返回值前,输出相关信息。最后输出n + (n-1)……+1的值

Input

3

Output

[plus1(3) output]Begin invoke plus1(3)
[plus1(3) output]I want to calculate plus1(3), require 3 and the value of plus1(2),so I need to invoke plus1(2)
[plus1(2) output]Begin invoke plus1(2)
[plus1(2) output]I want to calculate plus1(2), require 2 and the value of plus1(1),so I need to invoke plus1(1)
[plus1(1) output]Begin invoke plus1(1)
[plus1(1) output]return plus1(1) = 1
[plus1(2) output]I got the value of plus1(1), and plus it to 2then return3
[plus1(3) output]I got the value of plus1(2), and plus it to 3then return6
6

Sample Input

3

Sample Output

[plus1(3) output]Begin invoke plus1(3)[plus1(3) output]I want to calculate plus1(3), require 3 and the value of plus1(2),so I need to invoke plus1(2)[plus1(2) output]Begin invoke plus1(2)[plus1(2) output]I want to calculate plus1(2), require 2 and the value of plus1(1),so I need to invoke plus1(1)[plus1(1) output]Begin invoke plus1(1)[plus1(1) output]return plus1(1) = 1[plus1(2) output]I got the value of plus1(1), and plus it to 2then return3[plus1(3) output]I got the value of plus1(2), and plus it to 3then return66

Hint

int plus1(int a)
{
    // 从这里输出开始调用时的信息
    if(a == 1)
    {
        // 从这里输出最后一次调用的返回信息
        return ……;
    }
    else
    {
        // 从这里输出调用时的信息
        // 开始进行递归调用下一步
        ……
        int c = plus1(a - 1);
        // 从这里输出返回值前的信息
        ……
        return ……;
    }
}

Source

Sharpbai
清清白白的一个大水题,而我从一个多月之前直到现在还是做不出来。真是天苍苍那个野茫茫,有一人他想骂娘~~
据我自己分析,应当是某些细节上没弄好,以至于这样的基础题做不出来,丢人啊。
还有一些相对简单的题,要用到数组,并且是多组样例,加EOF。就因为我没有养成好习惯,听师哥和课本的话,用 memset 函数对他们进行初始化,而WA了无数次,不说了,说多了都是泪啊。
所谓细节决定成败,也就是如此吧,对于我们程序员来说尤为如此。
与其粗放式操作和学习,成为败犬,还不如变成患有完美主义强迫症的程序员来的潇洒,还可以独自在冷风中,无敌着,寂寞着,多帅~~

原创粉丝点击