HDU 5099 Comparison of Android versions(模拟-水题)
来源:互联网 发布:使命召唤12优化设置 编辑:程序博客网 时间:2024/05/16 18:53
Comparison of Android versions
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 226 Accepted Submission(s): 128
Problem Description
As an Android developer, itˇs really not easy to figure out a newer version of two kernels, because Android is updated so frequently and has many branches. Fortunately, Google identifies individual builds with a short build code, e.g. FRF85B.
The first letter is the code name of the release family, e.g. F is Froyo. The code names are ordered alphabetically. The latest code name is K (KitKat).
The second letter is a branch code that allows Google to identify the exact code branch that the build was made from, and R is by convention the primary release branch.
The next letter and two digits are a date code. The letter counts quarters, with A being Q1 2009. Therefore, F is Q2 2010. The two digits count days within the quarter, so F85 is June 24 2010.
Finally, the last letter identifies individual versions related to the same date code, sequentially starting with A; A is actually implicit and usually omitted for brevity.
Please develop a program to compare two Android build numbers.
The first letter is the code name of the release family, e.g. F is Froyo. The code names are ordered alphabetically. The latest code name is K (KitKat).
The second letter is a branch code that allows Google to identify the exact code branch that the build was made from, and R is by convention the primary release branch.
The next letter and two digits are a date code. The letter counts quarters, with A being Q1 2009. Therefore, F is Q2 2010. The two digits count days within the quarter, so F85 is June 24 2010.
Finally, the last letter identifies individual versions related to the same date code, sequentially starting with A; A is actually implicit and usually omitted for brevity.
Please develop a program to compare two Android build numbers.
Input
The first line is an integer n (1 <= n <= 2000), which indicates how many test cases need to process.
Each test case consists of a single line containing two build numbers, separated by a space character.
Each test case consists of a single line containing two build numbers, separated by a space character.
Output
For each test case, output a single line starting with ¨Case #: 〃 (# means the number of the test case). Then, output the result of release comparison as follows:
● Print "<" if the release of the first build number is lower than the second one;
● Print "=" if the release of the first build number is same as he second one;
● Print ">" if the release of the first build number is higher than the second one.
Continue to output the result of date comparison as follows:
● Print "<" if the date of the first build number is lower than the second one;
● Print "=" if the date of the first build number is same as he second one;
● Print ">" if the date of the first build number is higher than the second one.
If two builds are not in the same code branch, just compare the date code; if they are in the same code branch, compare the date code together with the individual version.
● Print "<" if the release of the first build number is lower than the second one;
● Print "=" if the release of the first build number is same as he second one;
● Print ">" if the release of the first build number is higher than the second one.
Continue to output the result of date comparison as follows:
● Print "<" if the date of the first build number is lower than the second one;
● Print "=" if the date of the first build number is same as he second one;
● Print ">" if the date of the first build number is higher than the second one.
If two builds are not in the same code branch, just compare the date code; if they are in the same code branch, compare the date code together with the individual version.
Sample Input
2FRF85B EPF21BKTU84L KTU84M
Sample Output
Case 1: > >Case 2: = <
Source
2014上海全国邀请赛——题目重现(感谢上海大学提供题目)
比较Android版本号,题意比较难搞清,If two builds are not in the same code branch, just compare the date code; if they are in the same code branch, compare the date code together with the individual version. 注意这句话。
#include <iostream>#include <cstdio>using namespace std;const int MAXN = 10;int nCase, cnt;char A[MAXN], B[MAXN];char judge() { for (int i = 2; i <= 4; i++) { if (A[i] != B[i]) { return A[i] < B[i] ? '<' : '>'; } } if (A[1] == B[1]) { char a = (A[5] == '\0' ? 'A' : A[5]); char b = (B[5] == '\0' ? 'A' : B[5]); return (a == b ? '=' : (a < b ? '<' : '>')); } return '=';}int main() { scanf("%d", &nCase); while (nCase--) { scanf("%s%s", A, B); char ch1 = (A[0] == B[0] ? '=' : (A[0] < B[0] ? '<' : '>')); char ch2 = judge(); printf("Case %d: %c %c\n", ++cnt, ch1, ch2); } return 0;}
0 0
- HDU 5099 Comparison of Android versions(模拟-水题)
- HDU 5099 Comparison of Android versions(模拟)
- hdu 5099 Comparison of Android versions(水题)
- HDU 5099 Comparison of Android versions【字符串+模拟】
- HDOJ 5099 Comparison of Android versions(字符串模拟)
- HDU 5099 Comparison of Android versions(上海邀请赛模拟水题)
- 【瞎搞】 HDU 5099 Comparison of Android versions
- HDU 5099 Comparison of Android versions
- HDU 5099 - Comparison of Android versions
- hdu 5099 Comparison of Android versions
- HDU 5099 Comparison of Android versions(字符串)
- HDU 5099 Comparison of Android versions(坑水题)
- Comparison of Android versions
- HDOJ 5099 Comparison of Android versions 坑题
- hdoj-5099-Comparison of Android versions
- hdoj.5099 Comparison of Android versions【字符串处理,水题】 2015/08/13
- Comparison of Android versions(2014上海全国邀请赛)
- hdu 5199 Comparison of Android version
- Linux系统增加交换空间的方法
- hdu 3262 Seat taking up is tough(暴力)
- 第10周项目5-输出完数
- 如何掌握并在实践中自如运用设计模式
- spring <context:annotation-config> 跟 <context:component-scan>诠释及区别
- HDU 5099 Comparison of Android versions(模拟-水题)
- Java编程:向枚举添加自定义属性(用for-each循环来打印每种苹果的名称和价格)
- 分享一张自己觉得很不错的Android学习线路图
- 菜鸟nginx源码剖析数据结构篇(十) 自旋锁ngx_spinlock
- 关于面向对象的的设计原则的使用
- LeeCode---Add Two Numbers
- C++ Primer再读笔记-1
- Cocos2d-x优化中多线程并发访问
- HDU 5095 Linearization of the kernel functions in SVM(模拟, 水题)