02:不吉利日期

来源:互联网 发布:大作家软件好用吗 编辑:程序博客网 时间:2024/04/27 14:49

02:不吉利日期


总时间限制: 
1000ms 
内存限制: 
65536kB
描述

在国外,每月的13号和每周的星期5都是不吉利的。特别是当13号那天恰好是星期5时,更不吉利。已知某年的一月一日是星期w,并且这一年一定不是闰年,求出这一年所有13号那天是星期5的月份,按从小到大的顺序输出月份数字。(w=1..7)

输入
输入有一行,即一月一日星期几(w)。(1 <= w <= 7)
输出
输出有一到多行,每行一个月份,表示该月的13日是星期五。
样例输入
7
样例输出
110
提示
1、3、5、7、8、10、12月各有31天
4、6、9、11月各有30天
2月有28天
来源
计算概论化学学院期末考试


#include <stdio.h>#include <iostream>#include <stack>#include <string.h>#include <queue>#include <cmath>#include <vector>#include <algorithm>#include <map>#include <set>#include <string>using namespace std;typedef long long LL;#define MAX 1001int a[MAX][MAX];int b[MAX][MAX];int res[MAX][MAX];int n, m;int day[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};int sumDay(int month){    int sumday = 0;    for(int i = 1; i < month; i++){        sumday += day[i];    }    sumday += 13;    return sumday;}int main() {    //freopen("in.txt", "r", stdin);    //freopen("out.txt", "w", stdout);    int n;    cin >> n;    for(int i = 1; i <= 12; i++){        if(((sumDay(i) - 1) % 7 + n) % 7 == 5){            cout << i << endl;        }    }    return 0;}


原创粉丝点击