HDOJ 2078 复习时间


题目地址:

http://acm.hdu.edu.cn/showproblem.php?pid=2078


不知道这题算不算贪心,只能说是水题~~~~

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
#include <iostream>
using namespace std;
int theMax, theMin;
int main() 
{
    int nCases;
    int m, n;
    cin >> nCases;
    while(nCases--)
    {
        theMax = 0; 
        theMin = 101;
        cin >> n >> m;
        int num;
        for(int i=0; i<n; ++i)
        {
           cin >> num;
           if(num < theMin)
              theMin = num;
           if(num > theMax)
              theMax = num;
        }
        if((theMax-theMin)*(theMax-theMin) < (100-theMin)*(100-theMin))
           printf("%d\n", (100-theMin)*(100-theMin));
        else
           printf("%d\n", (theMax-theMin)*(theMax-theMin));
     }
     return 0; 
}

发布者

Tanky Woo

Tanky Woo,[个人主页:https://tankywoo.com] / [新博客:https://blog.tankywoo.com]

发表评论

电子邮件地址不会被公开。 必填项已用*标注