PAT1061. Dating

Sherlock Holmes received a note with some strange strings: "Let‘s date!  3485djDkxh4hhGE  2984akDfkkkkggEdsb  s&hgsfdk  d&Hyscvnm".  It took him only a minute to figure out that those strange strings are actually referring to the coded time "Thursday 14:04" -- since the first common capital English letter (case sensitive) shared by the first two strings is the 4th capital letter ‘D‘, representing the 4th day in a week; the second common character is the 5th capital letter ‘E‘, representing the 14th hour (hence the hours from 0 to 23 in a day are represented by the numbers from 0 to 9 and the capital letters from A to N, respectively); and the English letter shared by the last two strings is ‘s‘ at the 4th position, representing the 4th minute.  Now given two pairs of strings, you are supposed to help Sherlock decode the dating time.

Input Specification:

Each input file contains one test case.  Each case gives 4 non-empty strings of no more than 60 characters without white space in 4 lines.

Output Specification:

For each test case, print the decoded time in one line, in the format "DAY HH:MM", where "DAY" is a 3-character abbreviation for the days in a week -- that is, "MON" for Monday, "TUE" for Tuesday, "WED" for Wednesday, "THU" for Thursday, "FRI" for Friday, "SAT" for Saturday, and "SUN" for Sunday.  It is guaranteed that the result is unique for each case.

Sample Input:

3485djDkxh4hhGE
2984akDfkkkkggEdsb
s&hgsfdk
d&Hyscvnm

Sample Output:

THU 14:04
思路:水题,一定要注意细节 基础里面有

 1 #include <iostream>
 2 #include <cstdio>
 3 using namespace std;
 4
 5 char str[4][80];
 6 char week[7][6]={
 7
 8     "MON",
 9     "TUE",
10     "WED",
11     "THU",
12     "FRI",
13     "SAT",
14     "SUN"
15 };
16 int main(int argc, char *argv[])
17 {
18     for(int i=0;i<4;i++)
19     {
20         scanf("%s",str[i]);
21     }
22     bool flag=false;
23     for(int i=0;str[0][i]!=‘\0‘&&str[1][i]!=‘\0‘;i++)
24     {
25         if(!flag&&str[0][i]==str[1][i]&&str[0][i]>=‘A‘&&str[0][i]<=‘G‘)
26         {
27             flag=true;;
28             int index=str[0][i]-‘A‘;
29             printf("%s ",week[index]);
30         }
31         else if(flag&&str[0][i]==str[1][i])
32         {
33             if(str[0][i]>=‘0‘&&str[0][i]<=‘9‘)
34             {
35                 printf("%02d:",str[0][i]-‘0‘);
36                 break;
37             }
38             else if(str[0][i]>=‘A‘&&str[0][i]<=‘N‘)
39             {
40                 printf("%02d:",str[0][i]-‘A‘+10);
41                 break;
42             }
43         }
44     }
45     int ans;
46     for(int i=0;str[2][i]!=‘\0‘&&str[3][i]!=‘\0‘;i++)
47     {
48         if(str[2][i]==str[3][i])
49         {
50             if(str[2][i]>=‘a‘&&str[2][i]<=‘z‘||str[2][i]>=‘A‘&&str[2][i]<=‘Z‘)
51             {
52                 ans=i;
53                 break;
54             }
55         }
56     }
57     printf("%02d\n",ans);
58
59     return 0;
60 }

时间: 2024-10-31 06:11:35

PAT1061. Dating的相关文章

pat1061. Dating (20)

1061. Dating (20) 时间限制 50 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Sherlock Holmes received a note with some strange strings: "Let's date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm". It took him only a minut

hdu 2579 Dating with girls(2)

题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2579 Dating with girls(2) Description If you have solved the problem Dating with girls(1).I think you can solve this problem too.This problem is also about dating with girls. Now you are in a maze and th

hdu 2578 Dating with girls(1)

题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2578 Dating with girls(1) Description Everyone in the HDU knows that the number of boys is larger than the number of girls. But now, every boy wants to date with pretty girls. The girls like to date with

HDU 2579 Dating with girls(2) (BFS)

Dating with girls(2) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2416    Accepted Submission(s): 690 Problem Description If you have solved the problem Dating with girls(1).I think you can

[2016-2-17]OMG美语每日笔记-Have you ever been use a dating app?Have you ever been catfished?

坚持!坚持!坚持~! dating app 交友应用 hesitant 犹豫 I have been single for a long time but I am a little hesitant to sign up for a dating app 我已经单身很久了但是我有点犹豫要不要再交由应用上注册 I heard the guys on dating apps aren't looking for real relationships. 我听说交有应用上的男人不是真的要找女朋友 to

hdu 2579 Dating with girls(2) 【经典三维BFS】

Dating with girls(2)                                                           Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2443    Accepted Submission(s): 697 链接:http://acm.hdu.edu.cn/showp

HDU 2578 Dating with girls(1) [补7-26]

Dating with girls(1) Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3869    Accepted Submission(s): 1196 Problem Description Everyone in the HDU knows that the number of boys is larger than the

机器学习 MLIA学习笔记(三)之 KNN(二) Dating可能性实例

这是个KNN算法的另一实例,计算Dating的可能性. import numpy as np import os import operator import matplotlib import matplotlib.pyplot as plt def classify(inX, dataSet, labels, k): dataSetSize = dataSet.shape[0]#lines num; samples num diffMat = np.tile(inX, (dataSetSiz

1061. Dating

Sherlock Holmes received a note with some strange strings: "Let's date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm". It took him only a minute to figure out that those strange strings are actually referring to the coded time &