浙江财经大学
信息管理与工程学院

PAT(A) 1061. Dating (20)

本文由 Ocrosoft 于 2016-12-26 23:25:51 发表

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 <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <ctime>
#include <string>
#include <cstdio>
#include <vector>
#include <cctype>
#include <climits>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
#define strend string::npos
#define ms(a) memset(a,0,sizeof(a))
#define  rep(a,v,b) for(int a=v;a<b;a++)
#define  repe(a,v,b) for(int a=v;a<=b;a++)
typedef long long LL;
const LL LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const int MAXN = 300000 + 10;
const int MOD = 1000000009;
int gcd(int a, int b)
{
	if (!b)return a;
	return gcd(b, a%b);
}
/*(◕‿‿◕) (◕‿‿◕) (◕‿‿◕) (◕‿‿◕) (◕‿‿◕)*/
/*(◕‿‿◕) 签订契约,成为马猴烧酒吧! (◕‿‿◕)*/
/*(◕‿‿◕) (◕‿‿◕) (◕‿‿◕) (◕‿‿◕) (◕‿‿◕)*/
using namespace std;
int main()
{
	string s1, s2, s3, s4;
	cin >> s1 >> s2 >> s3 >> s4;
	int mark = 0;
	for (int i = 0; i < s1.size() && i < s2.size(); i++)
	{
		if (s1[i] == s2[i] && (s1[i] >= 'A'&&s1[i] <= 'G'))
		{
			switch (s1[i])
			{
			case 'A':  cout << "MON "; break;
			case 'B':  cout << "TUE "; break;
			case 'C':  cout << "WED "; break;
			case 'D':  cout << "THU "; break;
			case 'E':  cout << "FRI "; break;
			case 'F':  cout << "SAT "; break;
			case 'G':  cout << "SUN "; break;
			}
			mark = i;
			break;
		}
	}
	for (int j = mark + 1; j < s1.size() && j < s2.size(); j++)
	{
		if (s1[j] == s2[j] && (s1[j] >= 'A' &&s1[j] <= 'N' || s1[j] >= '0'&&s1[j] <= '9'))
		{
			if (s1[j] >= 'A'&&s1[j] <= 'N')
			{
				int x = s1[j] - 'A' + 10;
				cout << x / 10 << x % 10 << ":";
			}
			else
			{
				int y = s1[j] - '0';
				cout << y / 10 << y % 10 << ":";
			}
			break;
		}
	}
	for (int k = 0; k < s3.size() && k < s4.size(); k++)
	{
		if (s3[k] == s4[k] && (s3[k] >= 'A'&&s3[k] <= 'Z' || s3[k] >= 'a'&&s3[k] <= 'z'))
		{
			cout << k / 10 << k % 10 << endl;
		}
	}
	return 0;
}

欢迎分享与转载,请保留链接与出处。Ocrosoft » PAT(A) 1061. Dating (20)

点赞 (0)or拍砖 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址