02:不吉利日期

02:不吉利日期


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

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

输入
输入有一行,即一月一日星期几(w)。(1 <= w <= 7)
输出
输出有一到多行,每行一个月份,表示该月的13日是星期五。
样例输入
7
样例输出
1
10
提示
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 1001
int 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;

}





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值