POJ - 2080 Calendar

题意:求2000.1.1(周六)过n天后,是哪年哪月哪日星期几

思路:看到过好多次了这种题,细心点模拟就是了

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

char w[7][10]={"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" ,"Saturday"};
int m[2][13]={0,31,28,31,30,31,30,31,31,30,31,30,31,
	0,31,29,31,30,31,30,31,31,30,31,30,31};
int yd[2]={365,366};
long long day;

int main(){
	int year,month,week;
	while (scanf("%lld", &day) != EOF && day!=-1){
		week = (day+6)%7;
		year = 2000;
		int flag = (year%4==0 && year%100!=0)||year%400==0;
		++day;
		while (day > yd[flag]){
			day -= yd[flag];
			year++;
			flag = (year%4==0 && year%100!=0)||year%400==0;
		}
		for (month = 1; day > m[flag][month]; month++)
			day -= m[flag][month];
		printf("%d-%02d-%02lld %s\n",year,month,day,w[week]);
	}
	return 0;
}

POJ - 2080 Calendar

时间: 2024-10-13 07:27:24

POJ - 2080 Calendar的相关文章

[sg简单应用] poj 1082 Calendar Game

这一篇文章专门整理一下研究过的Android面试题,内容会随着学习不断的增加,如果答案有错误,希望大家可以指正 1.简述Activity的生命周期 当Activity开始启动的时候,首先调用onCreate(),onStart(),onResume()方法,此时Activity对用户来说,是可见的状态 当Activity从可见状态变为被Dialog遮挡的状态的时候,会调用onPause()方法,此时的Activity对用户可见,但是不能相 应用户的点击事件 当Activity从可见状态变为被其他

poj 1079 Calendar Game(博弈论 SG)

Calendar Game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2519    Accepted Submission(s): 1438 Problem Description Adam and Eve enter this year's ACM International Collegiate Programming Co

Poj Maya Calendar

http://poj.org/problem?id=1008 Maya Calendar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 64607 Accepted: 19908 Description During his last sabbatical, professor M. A. Ya made a surprising discovery about the old Maya calendar. From an

POJ 2080

import java.util.*; public class Main { public static void main(String args[]){ Scanner cin=new Scanner(System.in); int num; while(true){ num=cin.nextInt(); if(num==-1) break; num_year(num); num_last(num); } } public static boolean judge_leap(int num

poj2080 Calendar

B - Calendar Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:30000KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 2080 Appoint description: System Crawler (2016-05-04) Description A calendar is a system for m

poj 1008:Maya Calendar(模拟题,玛雅日历转换)

Maya Calendar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 64795   Accepted: 19978 Description During his last sabbatical, professor M. A. Ya made a surprising discovery about the old Maya calendar. From an old knotted message, profes

[POJ] POJ1008 Maya Calendar

该篇作为POJ之路的起点,初学乍道,请多指教. Problem: Maya Calendar Description During his last sabbatical, professor M. A. Ya made a surprising discovery about the old Maya calendar. From an old knotted message, professor discovered that the Maya civilization used a 365

Poj OpenJudge 百练 Bailian 1008 Maya Calendar

1.Link: http://poj.org/problem?id=1008 http://bailian.openjudge.cn/practice/1008/ 2.content: Maya Calendar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 66971   Accepted: 20644 Description During his last sabbatical, professor M. A. Ya

[POJ] #1008# Maya Calendar : 字符处理/同余问题

一. 题目 Maya Calendar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 74085   Accepted: 22819 Description During his last sabbatical, professor M. A. Ya made a surprising discovery about the old Maya calendar. From an old knotted message,