2014上海全国邀请赛1010(hdu 5099)
2014-11-03 00:08
453 查看
Comparison of Android versions
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 67 Accepted Submission(s): 54
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.
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.
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.
Sample Input
2 FRF85B EPF21B KTU84L KTU84M
Sample Output
Case 1: > > Case 2: = <
题意:这题读题比较重要吧,第一个符号是比较第一个字符,第二个符号的判断是先看第二个字符是否相等,相等的话就比较最后四位字符,不相等的话就判断除了倒数第4-倒数第二位的字符。
做法:直接判断。
#include <iostream> #include <cstdio> #include <climits> #include <cstring> #include <cstdlib> #include <cmath> #include <vector> #include <queue> #include<map> #include <algorithm> #include<ctime> #define esp 1e-6 #define LL unsigned long long #define inf 0x0f0f0f0f using namespace std; int main() { int t,cas; int i; char s1[20],s2[20]; char a1[20],a2[20]; scanf("%d",&t); for(cas=1;cas<=t;cas++) { scanf("%s %s",s1,s2); printf("Case %d: ",cas); if(s1[0]==s2[0]) printf("="); else if(s1[0]>s2[0]) printf(">"); else printf("<"); int kk; if(s1[1]==s2[1]) { kk=0; for(i=2;i<=5;i++) a1[kk++]=s1[i]; a1[kk]='\0'; kk=0; for(i=2;i<=5;i++) a2[kk++]=s2[i]; a2[kk]='\0'; if(strcmp(a1,a2)<0) printf(" <\n"); else if(strcmp(a1,a2)==0) printf(" =\n"); else printf(" >\n"); } if(s1[1]!=s2[1]) { kk=0; for(i=2;i<=4;i++) a1[kk++]=s1[i]; a1[kk]='\0'; kk=0; for(i=2;i<=4;i++) a2[kk++]=s2[i]; a2[kk]='\0'; if(strcmp(a1,a2)<0) printf(" <\n"); else if(strcmp(a1,a2)==0) printf(" =\n"); else printf(" >\n"); } } }
相关文章推荐
- 2014上海全国邀请赛(hdu 5090 - 5099)dp+线段树+拓扑排序+bfs(状态压缩)
- 2014上海全国邀请赛1001(hdu 5090)
- hdu 5090 Game with Pearls 2014上海全国邀请赛——题目重现
- HDU5099——Comparison of Android versions(简单题)(2014上海邀请赛重现)
- HDU 5097 Page Rank(矩阵模拟)——2014上海全国邀请赛——题目重现(感谢上海大学提供题目)
- 2014上海全国邀请赛1003(hdu 5092)
- hdu 5092 Seam Carving 2014上海全国邀请赛——题目重现
- 2014上海全国邀请赛1006(hdu 5095)
- 2014上海全国邀请赛题解 HDOJ 5090-5099
- 【HDU】2014上海全国邀请赛——题目重现(感谢上海大学提供题目) 题解
- 2014上海全国邀请赛题解 HDOJ 5090-5099
- [HDU 4848][2014西安全国邀请赛]Wow! Such Conquering!
- 2014上海全国邀请赛 解题报告
- 2014上海全国邀请赛I题 Smart Software Installer(hdu5098)(top排序)
- Comparison of Android versions(2014上海全国邀请赛)
- 2014西安全国邀请赛 1003 && HDU 4849 Wow! Such City! (单源最短路Djikstra算法)
- HDU5093——Battle ships(最大二分匹配)(2014上海邀请赛重现)
- 2014上海全国邀请赛Maze
- 2014上海全国邀请赛训练总结【7/10】
- HDU5092——Seam Carving(动态规划+回溯)(2014上海邀请赛重现)