• 1061 Dating (20 分)


    1061 Dating (20 分)
     

    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 <bits/stdc++.h>
     2 
     3 using namespace std;
     4 string s2, s1;
     5 string st1, st2;
     6 string an[7] ={"MON","TUE","WED","THU","FRI","SAT","SUN"};
     7 int a[5]={0};
     8 int main(){
     9     cin >> s1 >> s2 >> st1 >> st2;
    10     int pos = 0;
    11     for(int i = 0; i < min(s1.length(), s2.length()); i++){
    12         if(pos == 0 && s1[i] == s2[i] && s1[i] >= 'A' && s1[i] <= 'G'){
    13             a[pos] = s1[i] - 'A';
    14             pos++;
    15         }else if(pos == 1 && s1[i] == s2[i]){
    16             if(s1[i] >= 'A' && s1[i] <= 'N'){
    17                 a[pos] = s1[i] - 'A';
    18                 a[pos] += 10;
    19                 pos++;
    20             }else if(s1[i]>='0' && s1[i]<='9'){
    21                 a[pos] = s1[i] - '0';
    22                 pos++;
    23             }
    24         }else if(pos == 2){
    25             break;
    26         }
    27     }
    28 
    29     for(int i = 0; i < min(st1.length(), st2.length()); i++){
    30         if(st1[i] == st2[i] && isalpha(st1[i]) ){
    31             a[pos++] = i;
    32             break;
    33         }
    34     }
    35 
    36     cout <<an[a[0]]<<" ";
    37     printf("%02d:%02d
    ", a[1], a[2]);
    38     return 0;
    39 }



  • 相关阅读:
    插头DP专题
    HDU 4873 ZCC Loves Intersection(JAVA、大数、推公式)
    HDU 4865 Peter's Hobby(概率、dp、log)
    HDU 4870 Rating(概率、期望、推公式) && ZOJ 3415 Zhou Yu
    HDU 4862 Jump(最小K路径覆盖)
    codeforces 449B Jzzhu and Cities (Dij+堆优化)
    2014 12th GDCPC 总结
    HDU 1693 Eat the Trees(插头DP、棋盘哈密顿回路数)+ URAL 1519 Formula 1(插头DP、棋盘哈密顿单回路数)
    UVALive 4949 Risk(二分网络流、SAP)
    Codeforces 1105D(双层广搜)
  • 原文地址:https://www.cnblogs.com/zllwxm123/p/11191666.html
Copyright © 2020-2023  润新知