zoukankan      html  css  js  c++  java
  • 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

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    using namespace std;
    int main(){
    	char a[62],b[62],c[62],d[62];
    	char s[8][4]={"MON","TUE","WED","THU","FRI","SAT","SUN"};
    	scanf("%s%s%s%s",a,b,c,d);
    	int dd;
    	char h;
    	int hh;
    	int m;
    	int i,j;
    	int len=strlen(a);
    	int index1=-1,index2=-1;
    	for(i=0;i<len;i++){
    		if(a[i]==b[i]){
    			if(index1==-1&&(a[i]>='A'&&a[i]<='G')){
    				index1=i;
    			}else if(index1!=-1&&index2==-1&&((a[i]>='A'&&a[i]<='N'||a[i]>='0'&&a[i]<='9'))){
    				index2=i;
    				break;
    			}
    		}
    	}
    	if(a[index1]>='A'&&a[index1]<='G'){
    		dd=a[index1]-'A';
    	}
    	h=b[index2];
    	if(h>='0'&&h<='9'){
    		hh=h-'0';
    	}else if(h>='A'&&h<='N'){
    		hh=h-'A'+10;
    	}
    	len=strlen(c);
    	int index=0;
    	for(i=0;i<len;i++){
    		if(c[i]==d[i]&&(c[i]>='A'&&c[i]<='Z'||c[i]>='a'&&c[i]<='z')){
    			index=i;
    			break;
    		}
    	}
    	printf("%s %02d:%02d
    ",s[dd],hh,index);
    	return 0;
    } 
    

      

  • 相关阅读:
    bfs输出路径 && 最短路(迪杰斯特拉)输出路径
    在Ubuntu虚拟机上搭建青岛OJ
    Delphi System.Fillchar 函数
    Delphi 类Class成员介绍 Private、protected、Public、Published
    通过带Flask的REST API在Python中部署PyTorch
    使用ONNX将模型转移至Caffe2和移动端
    AI框架类FAQ
    Paddle Release Note
    如何在框架外部自定义C++ OP
    如何写新的Python OP
  • 原文地址:https://www.cnblogs.com/grglym/p/7821274.html
Copyright © 2011-2022 走看看