【模拟】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的同学应该都非常了解了,但,对于前端而言,还是比较新颖的. 依赖注入,简而言之,就是解除硬编码,达到解偶的目的 ...
随机推荐
- java初学4
1.interface接口 (1)[修饰符] interface 接口名 extends 父接口1,父接口2.... •没有构造方法,不能实例化; •接口只能继承接口,不能 ...
- CentOS vim中backspace不能用,出现^?的解决方法
查看在VI配置器下面使用backspace删除时提示输出那个字符例如:^H.^?.^a等字符如果输出的是:^? 字符 则使用以下命令:[oracle@junyii~]$ stty erase ^? 再 ...
- 孤荷凌寒自学python第五十九天尝试使用python来读访问远端MongoDb数据服务
孤荷凌寒自学python第五十九天尝试使用python来读访问远端MongoDb数据服务 (完整学习过程屏幕记录视频地址在文末) 今天是学习mongoDB数据库的第五天.今天的感觉是,mongoDB数 ...
- [0] OpenCV_Notes - 琐碎
CV_8UC1,CV_8UC2,CV_8UC3等意思 一般的图像文件格式使用的是 Unsigned 8bits,CvMat矩阵对应的参数类型就是CV_8UC1,CV_8UC2,CV_8UC3.最后的C ...
- Nginx简单的配置详情
大致了解Nginx后,直接从配置文件入手: [shell] #定义Nginx运行的用户和用户组 user nginx; #nginx进程数,建议设置为等于CPU总核心数. worker_process ...
- 根文件系统制作、NFS配置与安装及利用NFS挂载根文件系统
最近打算从头开始制作根文件系统,下面是开发过程. 一.根文件系统的制作 0.FHS(Filesystem Hierarchy Standard)标准介绍 该标准规定了根目录下各个子目录的名称及其存放的 ...
- idea中新建的web项目不能新建servlet
============ ======================================================================== 在新建的“ java ”源文 ...
- mssql 格式化字符串 /时间 年月日时分秒
比如:1 想格式化 000001,100 格式化为000100: 思路是这样的 1000000 +格式化的数字 取后6位: select right(cast(power(10,6) as var ...
- Using Let’s Encrypt for free SSL Certs with Netscaler
Using Let’s Encrypt for free SSL Certs with Netscaler If you haven’t heard, Let’s Encrypt (https://l ...
- 设置RobotFramework的ftplibrary中,将Upload_file操作的异常改为回显错误信息。
测试中需要通过FTP通道,将数据发送给服务器,而这个上传的数据要被阻断.在结合RobotFramework测试中,安装的ftplibrary,使用upload_file操作,如果上传动作失败,会抛出异 ...