您的位置:首页 > 其它

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");
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: