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
- hdu1037
- hdu1037
- hdu1037
- HDU1037
- HDU1037
- HDU1037
- HDU1037:Keep on Truckin'
- hdu1037 Keep on Truckin'
- hdu1037 Keep on Truckin'
- HDU1037 - Keep on Truckin' (简单题)
- hdu1037 Keep on Truckin'(C语言)
- UVALive2857 POJ2578 HDU1037 ZOJ2186 Keep on Truckin'【水题】
- 转]Java中HashMap遍历的两种方式
- LeetCode 129 Sum Root to Leaf Numbers
- hdu 1052(田忌赛马 贪心算法,sort排序)
- final关键字(数据,方法,类)
- 最长公共上升子序列算法
- hdu1037
- java -jar
- Android学习——读书笔记
- 2014华为机试题9:通过键盘输入100以内正整数的加、减运算式
- HDU - 4941 Magical Forest
- 关于OC中的僵尸指针(野指针)
- DataTable相关操作,筛选,取前N条数据,去重复行,获取指定列数据
- spirng4集成jersey1.18
- 网线接错导致的网络打印机通讯异常