zoukankan      html  css  js  c++  java
  • 洛谷 P1202 [USACO1.1]黑色星期五Friday the Thirteenth

    黑色星期五

    难度:☆

    Code:

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    using namespace std;
    //Mystery_Sky
    //
    int day[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    int ans[8], N, date;
    int main() {
    	scanf("%d", &N);
    	bool flag_1 = false, flag_2 = false;
    	N = 1900 + N - 1;
    	for(int i = 1900; i <= N; i++) {
    		flag_1 = flag_2 = false;
    		if(i % 100 == 0) flag_2 = true;
    		if(flag_2 && i % 400 == 0) flag_1 = true;
    		else if(!flag_2 && i % 4 == 0) flag_1 = true;
    		if(flag_1) day[2] = 29;
    		for(int j = 1; j <= 12; j++) {
    			for(int k = 1; k <= day[j]; k++) {
    				date++;
    				date %= 7;
    				if(k == 13)
    					ans[date]++;				
    			}
    		}
    		day[2] = 28;
    	}
    	printf("%d %d ", ans[6], ans[0]);
    	for(int i = 1; i <= 5; i++) printf("%d ", ans[i]);
    	return 0;
    }
    
    唯愿,青春不辜负梦想,未来星辰闪耀
  • 相关阅读:
    django学习笔记(一)
    Python之函数进阶
    Python之函数初识
    Python之文件操作
    基础补充
    字典
    神奇的列表
    万能的字符串
    Python基础(二)
    使用paramiko进行ssh连接
  • 原文地址:https://www.cnblogs.com/Benjamin-cpp/p/10951777.html
Copyright © 2011-2022 走看看