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. libevent之event_base

    event_base是libevent的事务处理框架,负责事件注册.删除等,属于Reactor模式中的Reactor. event_base结构体 event_base结构体定义于<event_ ...

  2. 《java入门第一季》之面向对象(private关键字与封装概念的初探)

    /* 定义一个学生类: 成员变量:name,age 成员方法:show()方法 在使用这个案例的过程中,发现了一个问题: 通过对象去给成员变量赋值,可以赋值一些非法的数据.例如:name你赋值了一个3 ...

  3. OpenCV GUI基本操作,回调函数,进度条,裁剪图像等

    代码为转载,出处找不到了,不贴了 工具条进度条: // ConvertColor.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #incl ...

  4. RubyGem默认源安装太慢,修改国内淘宝源

    原帖地址:http://www.hiceon.com/topic/Ruby-Gem-install-source-taobao/ WHY? 由于国内网络原因(你懂的),导致 rubygems.org ...

  5. Linux下的 .o、.a、.so文件

    http://blog.sina.com.cn/s/blog_656681710100qzmy.html 工程里很多函数只是有声明,找不到实现的代码.因为那些实现代码已经编译成库所以看不见,我所看见的 ...

  6. 链路层 - SLIP,PPP,

    最常使用的封装格式是RFC 894定义的格式.图2 - 1显示了两种不同形式的封装格式.图中每个方框下面的数字是它们的字节长度. 两种帧格式都采用48 bit(6字节)的目的地址和源地址( 8 0 2 ...

  7. web报表工具FineReport常用函数的用法总结(数学和三角函数)

    最后一次抛砖引玉了,至此finereport所有的常见函数就分享完了,期待能对大家有些许帮助. ABS ABS(number):返回指定数字的绝对值.绝对值是指没有正负符号的数值. Number:需要 ...

  8. 【42】android Context深度剖析

    android程序和java程序的区别 Android程序不像Java程序一样,随便创建一个类,写个main()方法就能跑了,而是要有一个完整的Android工程环境,在这个环境下,我们有像Activ ...

  9. 关于Block的使用和5点注意事项

    一.概念 首先需要了解的是Block是一个代码块,是一个变量的形式存在的. 二.构成了解 我们需要在函数中声明block,因为是变量的形式,而且存在静态变量形式 类型1:  NSString* (^b ...

  10. C# 合并多种格式文件为PDF

    文档合并是一种高效文档处理方式.如果能够有一个方法能将多种不同类型的文档合并成一种文档格式,那么在文档存储管理上将为我们提供极大的便利.因此,本篇文章介绍了一种如何使用免费组件Free Spire.O ...