hdu1037

来源:互联网 发布:医院lis软件 编辑:程序博客网 时间:2024/05/23 16:54
Keep on Truckin'
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1037

Problem Description
Boudreaux and Thibodeaux are on the road again . . .

"Boudreaux, we have to get this shipment of mudbugs to Baton Rouge by tonight!"

"Don't worry, Thibodeaux, I already checked ahead. There are three underpasses and our 18-wheeler will fit through all of them, so just keep that motor running!"

"We're not going to make it, I say!"

So, which is it: will there be a very messy accident on Interstate 10, or is Thibodeaux just letting the sound of his own wheels drive him crazy?


Input
Input to this problem will consist of a single data set. The data set will be formatted according to the following description.

The data set will consist of a single line containing 3 numbers, separated by single spaces. Each number represents the height of a single underpass in inches. Each number will be between 0 and 300 inclusive.


Output
There will be exactly one line of output. This line will be:

NO CRASH

if the height of the 18-wheeler is less than the height of each of the underpasses, or:

CRASH X

otherwise, where X is the height of the first underpass in the data set that the 18-wheeler is unable to go under (which means its height is less than or equal to the height of the 18-wheeler).
The height of the 18-wheeler is 168 inches.


Sample Input

180  160  170




Sample Output

CRASH 160





解题思路:

        题意是说输入三个数,如果三个数都比168大,那么输出NO CRASH;否则第一个出现小于等于168的那个数。

        像这种益智题不用花太多时间考虑算法,但要追求优美的代码书写,拿这道题来说,我感觉一开始我那两个三

元运算符写的就很飘逸······




完整代码:

#include <functional>#include <algorithm>#include <iostream>#include <fstream>#include <sstream>#include <iomanip>#include <numeric>#include <cstring>#include <climits>#include <cassert>#include <complex>#include <cstdio>#include <string>#include <vector>#include <bitset>#include <queue>#include <stack>#include <cmath>#include <ctime>#include <list>#include <set>#include <map>using namespace std;#pragma comment(linker, "/STACK:102400000,102400000")typedef long long LL;typedef double DB;typedef unsigned uint;typedef unsigned long long uLL;/** Constant List .. **/ //{const int MOD = int(1e9)+7;const int INF = 0x3f3f3f3f;const LL INFF = 0x3f3f3f3f3f3f3f3fLL;const DB EPS = 1e-9;const DB OO = 1e20;const DB PI = acos(-1.0); //M_PI;void print(int x){    printf("CRASH %d\n",x);}int main(){    #ifdef DoubleQ    freopen("in.txt","r",stdin);    #endif    int a , b , c;    while(~scanf("%d%d%d",&a,&b,&c))    {        int minn = a > b ? b : a;        minn = c > minn ? minn : c;        if(minn > 168)        {            printf("NO CRASH\n");            continue;        }        int vis;        if(a <= 168)            print(a);        else if(b <= 168)            print(b);        else if(c <= 168)            print(c);    }}


0 0
原创粉丝点击