【模拟】Friday the Thirteenth
题目描述
That is, does the 13th of the month land on a Friday less often than on any other day of the week? To answer this question, write a program that will compute the frequency that the 13th of each month lands on Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday over a given period of N years. The time period to test will be from January 1, 1900 to December 31, 1900+N-1 for a given number of years, N. N is positive and will not exceed 400.
Note that the start year is NINETEEN HUNDRED, not 1990.
There are few facts you need to know before you can solve this problem:
January 1, 1900 was on a Monday.
Thirty days has September, April, June, and November, all the rest have 31 except for February which has 28 except in leap years when it has 29.
Every year evenly divisible by 4 is a leap year (1992 = 4*498 so 1992 will be a leap year, but the year 1990 is not a leap year)
The rule above does not hold for century years. Century years divisible by 400 are leap years, all other are not. Thus, the century years 1700, 1800, 1900 and 2100 are not leap years, but 2000 is a leap year.
Do not use any built-in date functions in your computer language.
Don't just precompute the answers, either, please.
输入
输出
样例输入
20
样例输出
36 33 34 33 35 35 34
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#define range(i,a,b) for(int i=a;i<=b;++i)
#define LL long long
#define rerange(i,a,b) for(int i=a;i>=b;--i)
#define fill(arr,tmp) memset(arr,tmp,sizeof(arr))
using namespace std;
string a,b;
LL mul1,mul2;
void init(){
cin>>a>>b;
mul1=mul2=;
}
void solve(){
range(i,,a.size()-)mul1*=a[i]-'A'+;
range(i,,b.size()-)mul2*=b[i]-'A'+;
cout<<(mul1%==mul2%?"GO":"STAY")<<endl;
}
int main() {
init();
solve();
return ;
}
【模拟】Friday the Thirteenth的更多相关文章
- Friday the Thirteenth 黑色星期五 USACO 模拟 超级简单做法
1003: 1.1.3 Friday the Thirteenth 黑色星期五 时间限制: 1 Sec 内存限制: 128 MB提交: 8 解决: 8[提交] [状态] [讨论版] [命题人:外部 ...
- [模拟]P1202 [USACO1.1]黑色星期五Friday the Thirteenth
原题 解析: 坑 其实.样例的部分是从周六~周五输出的,习惯不同吧..这里考虑到从这个月的13号到下一个月的13号所花天数为这个月的天数,然后愉快的判断一下闰年即可.这里的周一~周日编号为0~6,一月 ...
- USACO Section 1.1-3 Friday the Thirteenth
Friday the Thirteenth 黑色星期五 13号又是一个星期五.13号在星期五比在其他日子少吗?为了回答这个问题,写一个程序,要求计算每个月的十三号落在周一到周日的次数. 给出N年的一个 ...
- USACO-Friday the Thirteenth(黑色星期五)-Section1.2<3>
[英文原题] Friday the Thirteenth Is Friday the 13th really an unusual event? That is, does the 13th of t ...
- App开发:模拟服务器数据接口 - MockApi
为了方便app开发过程中,不受服务器接口的限制,便于客户端功能的快速测试,可以在客户端实现一个模拟服务器数据接口的MockApi模块.本篇文章就尝试为使用gradle的android项目设计实现Moc ...
- 故障重现, JAVA进程内存不够时突然挂掉模拟
背景,服务器上的一个JAVA服务进程突然挂掉,查看产生了崩溃日志,如下: # Set larger code cache with -XX:ReservedCodeCacheSize= # This ...
- Python 爬虫模拟登陆知乎
在之前写过一篇使用python爬虫爬取电影天堂资源的博客,重点是如何解析页面和提高爬虫的效率.由于电影天堂上的资源获取权限是所有人都一样的,所以不需要进行登录验证操作,写完那篇文章后又花了些时间研究了 ...
- HTML 事件(四) 模拟事件操作
本篇主要介绍HTML DOM中事件的模拟操作. 其他事件文章 1. HTML 事件(一) 事件的介绍 2. HTML 事件(二) 事件的注册与注销 3. HTML 事件(三) 事件流与事件委托 4. ...
- 模拟AngularJS之依赖注入
一.概述 AngularJS有一经典之处就是依赖注入,对于什么是依赖注入,熟悉spring的同学应该都非常了解了,但,对于前端而言,还是比较新颖的. 依赖注入,简而言之,就是解除硬编码,达到解偶的目的 ...
随机推荐
- 测试基础面试题 + SQL 面试题(选择题有部分答案,难度:低)
测试基础面试题 + SQL 面试题(选择题有部分答案,难度:低) 答案: .A .C .C .A .A .D
- day06_03 购物车讲解01
1.0 思路 1.1 列表嵌套 # name1 = ['mac','book','bike','kindle'] a = [[1,2,3],'alex',(2,3,4)] print(a[0]) #& ...
- Unity-SendMessage
每一个对象都有SendMessage,BroadcastMessage,SendMessageUpwards 三个发送消息的方法! 1.功能: 执行某个对象中的某个方法! 2.实现原理 反射 ...
- [OpenCV] Ptr类模板
1.C++泛型句柄类 我们知道在包含指针成员的类中,需要特别注意类的复制控制,因为复制指针时只复制指针中的地址,而不会复制指针指向的对象.这将导致当两个指针同时指向同一对象时,很可能一个指针删除了一对 ...
- hnust 档案管理
问题 E: 档案管理 时间限制: 1 Sec 内存限制: 128 MB提交: 274 解决: 105[提交][状态][讨论版] 题目描述 X老师管理着学校的档案室,经常会有其他的老师来档案室存文件 ...
- 聊聊、Spring WebApplicationInitializer
说到 WebApplicationInitializer,这个接口是为了实现代码配置 Web 功能.只要实现了这个接口,那么就可以实现 Filter,Servlet,Listener 等配置,跟在 x ...
- 转载css3 图片圆形显示 如何CSS将正方形图片显示为圆形图片布局
转载 原文:http://www.divcss5.com/wenji/w732.shtml 原本不是圆形图片,通过CSS样式布局实现成圆形图片,首先图片必须为正方形. 二.使用布局技术 - ...
- IPV4的地址是如何分类的?网络号的范围分别是多少?
1. A类地址 (1)A类地址第1字节为网络地址,其它3个字节为主机地址. (2)A类地址范围:1.0.0.1—126.255.255.254 (3)A类地址中的私有地址和保留地址: ① 10.X.X ...
- 第十二篇:HTML基础
本篇内容 HTML概述 HTML常用基本标签 CSS格式引入 一. HTML概述 1.定义: HTML,超文本标记语言,写给浏览器的语言,目前网络上应用最广泛的语言.HTML也在不断的更新,最新版本已 ...
- 【Luogu】P2490黑白棋(博弈DP)
题目链接 题解链接 #include<cstdio> #include<cstring> #include<algorithm> #include<cstdl ...