1061. Dating (20)

时间限制
150 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 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

思路
字符串处理问题,根据题目要求处理好就行,比较考验细心和耐心。
注意第一个字母的范围在A到G7个字母内(代表一周七天),第二个相同的字符是0到9以及A到N(10点到23点)。第三个字符是另外两个字符串共有的相同位置的英文字符。
最后的输出要转换成时间形式,因此要注意0到9的数字需要用00到09这样的形式表示。 代码
#include<iostream>
#include<vector>
#include<math.h>
using namespace std; vector<string> week = {"MON","TUE","WED","THU","FRI","SAT","SUN"}; int main()
{
string s1,s2,s3,s4;
while(cin >> s1 >> s2 >> s3 >> s4)
{
int len1 = min(s1.size(),s2.size()),len2 = min(s3.size(),s4.size());
vector<int> key();
int i = ;
for(;i < len1; i++)
{
if(s1[i] == s2[i] && (s1[i] >= 'A' && s1[i] <='G'))
{
key[] = s1[i] - 'A';
break;
}
} for(int j = i + ;j < len1;j++)
{
if(s1[j] == s2[j])
{
if(s1[j] <= '' && s1[j] >= '')
{
key[] = s1[j] - '';
break;
}
else if(s1[j] >= 'A' && s1[j] <= 'N')
{
key[] = s1[j] - 'A' + ;
break;
}
}
} for(int j = ; j < len2;j++)
{
if(s3[j] == s4[j] &&((s3[j] >= 'a' && s3[j] <= 'z') || (s3[j] >= 'A' && s3[j] <= 'Z')))
{
key[] = j;
break;
}
} cout << week[key[]] << " " ;
if(key[] < )
cout << "" << key[] <<":";
else
cout << key[] << ":";
if(key[] < )
cout <<"" << key[] << endl;
else
cout << key[] << endl;
}
}

PAT1061:Dating的更多相关文章

  1. pat1061. Dating (20)

    1061. Dating (20) 时间限制 50 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Sherlock Holmes ...

  2. hdu 2579 Dating with girls(2)

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2579 Dating with girls(2) Description If you have sol ...

  3. hdu 2578 Dating with girls(1)

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2578 Dating with girls(1) Description Everyone in the ...

  4. 10 signs you’re dating the wrong person

    10 signs you’re dating the wrong person10个迹象表明TA不是你的真心人       Do you have any exes who were so awful ...

  5. hdoj 2579 Dating with girls(2)【三重数组标记去重】

    Dating with girls(2) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  6. Dating with girls(1)(二分+map+set)

    Dating with girls(1) Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  7. Shine we together: A innovative dating site using 2012 Nobel Laureate Roth's algorithm

    Abstract Our dating site introduced scoring and its related functionalities innovatively, conforming ...

  8. Codeforces 852I Dating 树上莫队

    Dating 随便树上莫队搞一搞就好啦. #include<bits/stdc++.h> #define LL long long #define LD long double #defi ...

  9. A1061. Dating

    Sherlock Holmes received a note with some strange strings: "Let's date! 3485djDkxh4hhGE 2984akD ...

随机推荐

  1. android 自定义下拉菜单

    本实例的自定义下拉菜单主要是继承PopupWindow类来实现的弹出窗体,各种布局效果可以根据自己定义设计.弹出的动画效果主要用到了translate.alpha.scale,具体实现步骤如下: 先上 ...

  2. startService与bindService的区别

    转自:http://www.devdiv.com/thread-52226-1-1.html Service的生命周期方法比Activity少一些,只有onCreate, onStart, onDes ...

  3. C# FTPClient--FTP操作帮助类,上传下载,文件,目录操作

    FROM :http://www.sufeinet.com/forum.php?mod=viewthread&tid=1736&extra=page%3D1%26filter%3Dty ...

  4. HBase Muti-Master

    为了保证HBase集群的高可靠性,HBase支持多Backup Master 设置.当Active Master挂掉后,Backup Master可以自动接管整个HBase的集群. 该配置极其简单: ...

  5. c++ list 合并操作函数实例

    #include <list> #include <iostream> using namespace std; //list 链表的打印 void print(list< ...

  6. rails将类常量重构到数据库对应的表之后记

    怎么还有啊!别急,有强迫症的人伤不起!有点小事没说完感觉痒痒的:就是如果表payment_types经常变动该怎么办?每次都要关闭rails网页服务器,然后重启吗?那也太麻烦鸟,最终的解决方案是,在O ...

  7. C# 创建Word项目标号列表、多级编号列表

    在Word文档中,对于有多条并列的信息内容或者段落时,我们常以添加项目标号的形式来使文档条理化,在阅读时,文档也更具美观性.另外,对于在逻辑上存在一定层级结构的内容时,也可以通过多级编号列表来标明文档 ...

  8. Spring Boot 添加jersey-mvc-freemarker依赖后内置tomcat启动不了解决方案

    我在我的Spring Boot 项目的pom.xml中添加了jersey-mvc-freemarker依赖后,内置tomcat启动不了. 报错信息如下: org.springframework.con ...

  9. 超精简易用cocoaPods的安装和使用

    cocoaPods 安装和使用 第一步:替换ruby源 $ gem sources -l                                查看当前ruby的源 $ gem sources ...

  10. 简单了解JS中的几种遍历

    忙了好一段时间,项目上线后终于有那么一点点空档期静下来整理一些问题了.当我们在开发项目的时候,用到遍历的地方肯定少不了,那么我们有那么多的遍历方法,在不同情况下用那种方法会更优雅而且还没bug呢? 首 ...