ACM-ICPC Live Archive 第4889题 Post Office
来源:互联网 发布:美橙域名证书下载 编辑:程序博客网 时间:2024/04/29 00:00
ACM-ICPC Live Archive 第4889题,Post Office(题目链接)。
Post Office
Problem Description
Other than postcards, the post office department of some country recognizes three classes of mailable items: letters, packets, and parcels. The three dimensions of a mailable item are called length, height and thickness, with length being the largest and thickness the smallest of the three dimensions.
A letter's length must be at least 125mm but not more than 290mm, its height at least 90mm but not more than 155mm, and its thickness at least 0.25mm but not more than 7mm. (The unit millimeter is abbreviated by mm.)
All three of a packet's dimensions must be greater than or equal to the corresponding minimum dimension for a letter, and at least one of its dimensions must exceed the corresponding maximum for a letter. Furthermore, a packet's length must be no more than 380mm, its height no more than 300mm, and its thickness no more than 50mm.
All three of a parcel's dimensions must be greater than or equal to the corresponding minimum dimension for a letter, and at least one of its dimensions must exceed the corresponding maximum for a packet. Furthermore, the parcel's combined length and girth may not exceed 2100mm. (The girth is the full perimeter measured around the parcel, perpendicular to the length.)
Input
The input will contain data for a number of problem instances. For each problem instance, the input will consist of the three dimensions (measured in mm) of an item, in any order. The length and width will be positive integers. The thickness will be either a positive integer or a positive floating point number. The input will be terminated by a line containing three zeros.
Output
For each problem instance, your program will classify the item as letter, packet, parcel or not mailable. This verdict will be displayed at the beginning of a new line, in lower case letters.
Sample Input
100 120 100
0.5 100 200
100 10 200
200 75 100
0 0 0
Sample Output
not mailable
letter
packet
parcel
这题目没有任何难度。先进行一次排序。最长的作为length,中等长度的作为height,最短的作为thickness。然后判断length ≥ 125且height ≥ 90且thickness ≥ 0.25是否满足。如果不满足,那就输出not mailable,否则,如果length ≤ 290且height ≤ 155且thickness ≤ 7是否满足,如果满足,则输出letter,否则,判断length ≤ 380且height ≤ 300且thickness ≤ 50是否成立,如果成立,输出packet,否则,判断length + girth ≤ 2100是否成立,如果成立,输出parcel,否则,输出not mailable。C语言代码如下:
/**** ACM-ICPC Live Archive 第4889题 Post Office**** 叶剑飞* 2012年10月2日********************************************************************************/#include <stdio.h>#include <stdlib.h>void swap ( double * a, double * b ){ double temp = *a; *a = *b; *b = temp;}int main (void){ double temp; double length, height, thickness; while ( scanf( "%lf%lf%lf", &length, &height, &thickness ) , length || height || thickness ) { if ( length < height ) swap( &length, &height ); if ( length < thickness ) swap( &length, &thickness ); if ( height < thickness ) swap( &height, &thickness ); if ( length >= 125 && height >= 90 && thickness >= 0.25 ) { if ( length <= 290 && height <= 155 && thickness <= 7 ) puts( "letter" ); else if ( length <= 380 && height <= 300 && thickness <= 50 ) puts( "packet" ); else if ( length + height + height + thickness + thickness <= 2100 ) puts( "parcel" ); else puts( "not mailable" ); } else puts( "not mailable" ); } return EXIT_SUCCESS;}
- ACM-ICPC Live Archive 第4889题 Post Office
- ACM-ICPC Live Archive 6505---Metal(二分)
- ACM-ICPC Live Archive 6811 - Irrigation Lines
- ACM-ICPC Live Archive - Home 4329 - Ping pong
- acm/icpc live archive 2481, world final 2002 problem h. silly sort
- acm/icpc live archive regional 1998 europe central problem d, spoj 45 commedia dell arte
- ACM-ICPC Live Archive 6139 - Interval Product (线段树-点更新)
- UVALive 6270 (ACM-ICPC Live Archive: 6270) Edge Case(大数斐波那契)
- UVALive 6275 (ACM-ICPC Live Archive: 6275 ) Joint Venture(二分)
- ACM-ICPC Live Archive Regionals 2014 >> 重拾2014上海区域赛
- ACM-ICPC Live Archive 2031 - Dance Dance Revolution(状态dp)
- 贪心--ACM-ICPC Live Archive3902 Networkt
- ACM POJ 1160 Post Office
- AMC-ICPC Live Archive 7295 和 CSU 1715
- UVA Live 5067/acm-icpc-Asia - Tokyo-A
- [刷题]ACM/ICPC 2016北京赛站网络赛 第1题 第3题
- ACM-ICPC-ChinaFinal-H题
- live archive 4212 - Candy
- NEUOJ第1155题 Mysterious Organization —— 顺便训练一下“正则表达式”
- 吉林大学OJ第2775题 Problem F: Shadows
- 杭电OJ第4018题 Parsing URL
- 杭电OJ第4011题 Working in Beijing
- 杭电OJ第4015题 Mario and Mushrooms
- ACM-ICPC Live Archive 第4889题 Post Office
- BNU OJ 第26303 题 Touchscreen Keyboard
- C++ 11 STL 线程库实现的线程同步与互斥
- C++11标准 STL正则表达式 验证电子邮件地址
- POSIX正则表达式 验证电子邮件地址
- 湖南省第八届大学生计算机程序设计竞赛D题 平方根大搜索
- boost正则表达式 验证电子邮件地址
- 湖南省第八届大学生计算机程序设计竞赛C题 Updating a Dictionary
- JavaScript正则表达式 验证电子邮件地址