PAT1061:Dating
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 思路
字符串处理问题,根据题目要求处理好就行,比较考验细心和耐心。
注意第一个字母的范围在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的更多相关文章
- pat1061. Dating (20)
1061. Dating (20) 时间限制 50 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Sherlock Holmes ...
- hdu 2579 Dating with girls(2)
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2579 Dating with girls(2) Description If you have sol ...
- hdu 2578 Dating with girls(1)
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2578 Dating with girls(1) Description Everyone in the ...
- 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 ...
- hdoj 2579 Dating with girls(2)【三重数组标记去重】
Dating with girls(2) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- Dating with girls(1)(二分+map+set)
Dating with girls(1) Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- 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 ...
- Codeforces 852I Dating 树上莫队
Dating 随便树上莫队搞一搞就好啦. #include<bits/stdc++.h> #define LL long long #define LD long double #defi ...
- A1061. Dating
Sherlock Holmes received a note with some strange strings: "Let's date! 3485djDkxh4hhGE 2984akD ...
随机推荐
- UML之结尾篇
作为十期的孩子,我们已经开发过两个系统,学生管理系统和机房收费系统,也接触了软工,编写了一系列文档,不知道小朋友有没有这种感觉,开发一个系统软件和编写一个程序是不一样的,他们之间的差别,用一个比喻来说 ...
- cocos2d-x action执行完毕的回调
cocos2d-x action执行完毕的回调 MySprite::createOne() { .... // MUST add to sheet firstly spriteShee ...
- zookeeper+kafka集群安装之二
zookeeper+kafka集群安装之二 此为上一篇文章的续篇, kafka安装需要依赖zookeeper, 本文与上一篇文章都是真正分布式安装配置, 可以直接用于生产环境. zookeeper安装 ...
- javase--day_01
一.关键字: /* 关键字: 被java语言复与特定含义的单词. 特点: 组成关键字单词的字母全部小写. 注意: A:goto和c ...
- 一键安装Android开发环境
一键安装Android开发环境 1 下载tadp-3.0r4-linux-x64.run 进入下面的地址下载: https://developer.nvidia.com/gameworksdownlo ...
- Collections.sort自定义排序的使用方法
Collections.sort自定义排序的使用方法 总结:Collections可以对List进行排序:如果想对Map进行排序,可以将Map转化成List,进行排序: public static v ...
- datetimepicker日期框选择后,无法触发bootstrapValidator
如上图所示,当选择日期后下面的"栏位不能为空"提示并不能及时的消失,同时点击提交按钮也没有用. 解决如下: 在birthday的校验规则里面添加trigger:'change',就 ...
- spring3.1文档目录翻译
整理google共享磁盘找到了2014年翻译的spring官方文档的目录,分享出来可能会对英语不好的同学有些帮助吧. spring3.1官方文档目录-中文 spring3.1官方文档-英文 关于作者
- flask开发过程中的常见问题
1. 使用supervisorctl时报"http://localhost:9001 refused connection"错误 解决方法:使用supervisorctl时指定配置 ...
- FFPLAY的原理(三)
播放声音 现在我们要来播放声音.SDL也为我们准备了输出声音的方法.函数SDL_OpenAudio()本身就是用来打开声音设备的.它使用一个叫做SDL_AudioSpec结构体作为参数,这个结构体中包 ...