zoukankan      html  css  js  c++  java
  • Codeforces Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) A. Checking the Calendar(水题)

    传送门

    Description

    You are given names of two days of the week.

    Please, determine whether it is possible that during some non-leap year the first day of some month was equal to the first day of the week you are given, while the first day of the next month was equal to the second day of the week you are given. Both months should belong to one year.

    In this problem, we consider the Gregorian calendar to be used. The number of months in this calendar is equal to 12. The number of days in months during any non-leap year is: 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31.

    Names of the days of the week are given with lowercase English letters: "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday".

    Input

    The input consists of two lines, each of them containing the name of exactly one day of the week. It's guaranteed that each string in the input is from the set "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday".

    Output

    Print "YES" (without quotes) if such situation is possible during some non-leap year. Otherwise, print "NO" (without quotes).

    Sample Input

    monday
    tuesday
    sunday
    sunday
    saturday
    tuesday

    Sample Output

    NO

    YES

    YES

    思路

     题意:给出一星期中的两天,问他们有没有可能是平年中连续的两个月的头一天。

    注意tuesday thursday和thursday tuesday不是同种情况就可以了。

     
    #include<bits/stdc++.h>
    using namespace std;
    
    int main()
    {
    	int x,y;
    	int a[5] = {29,31,32};
    	string str1,str2;
    	cin >> str1 >> str2;
    	if (str1 == "monday")	x = 1;		if (str2 == "monday")	y = 1;
    	if (str1 == "tuesday")	x = 2;		if (str2 == "tuesday")	y = 2;
    	if (str1 == "wednesday")	x = 3;	if (str2 == "wednesday")	y = 3;
    	if (str1 == "thursday")	x = 4;		if (str2 == "thursday")	y = 4;
    	if (str1 == "friday")	x = 5;		if (str2 == "friday")	y = 5;
    	if (str1 == "saturday")	x = 6;		if (str2 == "saturday")	y = 6;
    	if (str1 == "sunday")	x = 7;		if (str2 == "sunday")	y = 7;
    	bool flag = false;
    	if (y >= x)
    	{
    		for (int i = 0;i < 3;i++)
    		{
    			if (a[i] % 7 == y - x + 1) 
    			{
    				flag = true;
    				break;
    			}
    		}
    		if (flag)	printf("YES
    ");
    		else	printf("NO
    ");
    	}
    	else
    	{
    		for (int i = 0;i < 3;i++)
    		{
    			if (a[i] % 7 == 7 - x + 1 + y)
    			{
    				flag = true;
    				break;
    			}
    		}
    		if (flag)	printf("YES
    ");
    		else	printf("NO
    ");
    	}
    	return 0;
    }
    

      

     
  • 相关阅读:
    ArcGIS三种方式打断相交线------Feature To Line工具
    ArcGIS三种方式打断相交线------Planarize Lines工具
    3种方法快速制作tpk文件 [转]
    将oracle冷备份恢复到另外一个数据库实例中
    常用ArcGIS for Silverlight 开发API介绍
    Bear + Reminders 是完美的Thing 3 的替代品
    2019科技盛会汇总
    电子产品使用感受之——为什么我把Apple Watch S2 升级到了 S4?
    我了解到的新知识之——电热水器用电安全
    我了解到的新知识之----遇到路由器DNS被篡改我该怎么办?
  • 原文地址:https://www.cnblogs.com/ZhaoxiCheung/p/5947149.html
Copyright © 2011-2022 走看看