1061. Dating
来源:互联网 发布:台湾士林夜市 知乎 编辑:程序博客网 时间:2024/05/17 05:32
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&HyscvnmSample Output:
THU 14:04
#include<stdio.h>#include<string.h>#include<iostream>using namespace std;string Day[7] = {"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};int main(){//freopen("F://Temp/input.txt", "r", stdin);string s1, s2, s3, s4;cin>>s1>>s2>>s3>>s4;int day, hour, min = -1;bool hasday = false;//有没有找到是星期几 for(int i=0,j=0; i<s1.size() && j<s2.size(); i ++, j ++){if(s1[i] == s2[j] && (s1[i]>='A' && s1[i]<='G' && !hasday)){day = s1[i] - 'A';hasday = true;}else if(s1[i] == s2[j] && (s1[i]>='0' && s1[i]<='9' || s1[i]>='A' && s1[i]<='N') && hasday){if(s1[i] >= '0' && s1[i] <= '9'){hour = s1[i] -'0';break;}else{hour = s1[i] - 'A' + 10;break;}}}for(int i=0,j=0; i<s3.size() && j<s4.size(); i ++, j ++){if(s3[i] == s4[j] && (s3[i]>='a' && s3[i]<='z' || s3[i]>='A' && s3[i]<='Z')){min = i;break;}}printf("%s %02d:%02d\n", Day[day].c_str(), hour, min);return 0;}
- 1061. Dating
- 1061.Dating
- 1061. Dating
- 1061. Dating
- 1061. Dating
- 1061. Dating
- 1061. Dating (20)-PAT
- 【PAT】1061. Dating (20)
- 1061. Dating (20)
- 1061. Dating (20)
- 1061. Dating (20)
- PAT 1061. Dating
- PAT 1061. Dating
- PAT 1061. Dating (20)
- pat 1061. Dating (20)
- 1061. Dating (20)
- 1061. Dating (20)
- 1061. Dating (20)
- zookeeper原理(转)
- poj 3667 Hotel 区间合并
- 直接把View Controller的view addSubview到另一个View,则不会调用viewDidAppear viewWillAppear
- Python:利用turtle库绘制iPhone4草图
- pictureviewer学习记录
- 1061. Dating
- 搭建git服务器之二:gitosis
- 本地通知(设置铃声图标和启动图片)
- iOS使用xib自定义UIView
- javascript性能优化
- com.alibaba.fastjson.JSONObject.getString耗时问题
- 源代码解析Servlet生命周期 转自segmentfault
- HDU 4337 暴力
- CodeForces 253D Table with Letters - 2