POJ
//poj 2080
//题目大意:给定天数,从2000年1月1日经过这些天后的 年 月 日 及 星期几
//代码参照大牛的写的,本人还是处于菜鸟阶段,思路很好
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
#include<math.h>
#include<algorithm>
using namespace std;
#define N 1100 int IsLeap(int y)
{
return ((y%4==0&&y%100!=0) || (y%400==0));
} int main()
{
int n, ansy, ansm, ansd, answ;
int tab[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}};
char s[7][10]={{"Saturday"}, {"Sunday"}, {"Monday"}, {"Tuesday"},
{"Wednesday"}, {"Thursday"}, {"Friday"}}; while(scanf("%d", &n), n!=-1)
{
ansy=2000;
ansm=1;
ansd=1;
answ=n%7;
while(n)
{
if(IsLeap(ansy))
{
if(n>=366)
{
n-=366;
ansy++;
}
else
{
if(n>=tab[IsLeap(ansy)][ansm])
{
n-=tab[IsLeap(ansy)][ansm];
ansm++;
}
else
{
ansd+=n;
n=0;
}
}
}
else
{
if(n>=365)
{
n-=365;
ansy++;
}
else
{
if(n>=tab[IsLeap(ansy)][ansm])
{
n-=tab[IsLeap(ansy)][ansm];
ansm++;
}
else
{
ansd+=n;
n=0;
}
}
}
}
printf("%d-%02d-%02d %s\n", ansy, ansm, ansd, s[answ]);
}
return 0;
}
POJ的更多相关文章
- POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
- POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
- POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22286 ...
- POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法
Flip Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37427 Accepted: 16288 Descr ...
- POJ 3254. Corn Fields 状态压缩DP (入门级)
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9806 Accepted: 5185 Descr ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
- POJ 2255. Tree Recovery
Tree Recovery Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11939 Accepted: 7493 De ...
- POJ 2752 Seek the Name, Seek the Fame [kmp]
Seek the Name, Seek the Fame Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 17898 Ac ...
- poj 2352 Stars 数星星 详解
题目: poj 2352 Stars 数星星 题意:已知n个星星的坐标.每个星星都有一个等级,数值等于坐标系内纵坐标和横坐标皆不大于它的星星的个数.星星的坐标按照纵坐标从小到大的顺序给出,纵坐标相同时 ...
- poj 1251 Jungle Roads (最小生成树)
poj 1251 Jungle Roads (最小生成树) Link: http://poj.org/problem?id=1251 Jungle Roads Time Limit: 1000 ...
随机推荐
- Excel对比两张表的某一列,匹配上则进行数据copy
VLOOKUP(参数1,参数2,参数3,参数4) 参数1: 查找值 参数2:指定查找数据源的范围 参数3:返回查找区域的第几列数据 参数4:精确查找输入参数"0"or"f ...
- Feign源码解析:初始化过程(一)
前言 打算系统分析下Feign的代码,上一篇讲了下Feign的历史,本篇的话,先讲下Feign相关的beanDefinition,beanDefinition就是bean的设计图,bean都是按照be ...
- 深入 K8s 网络原理(一)- Flannel VXLAN 模式分析
目录 1. 概述 2. TL;DR 3. Pod 间通信问题的由来 4. 测试环境准备 5. 从 veth 设备聊起 6. 网桥 cni0 6.1 在 Pod 内看网卡信息 6.2 在 host 上看 ...
- Scrapy-CrawlSpider爬虫类使用案例
CrawlSpider类型的爬虫会根据指定的rules规则自动找到url比自动爬取. 优点:适合整站爬取,自动翻页爬取 缺点:比较难以通过meta传参,只适合一个页面就能拿完数据的. import s ...
- Golang实现JAVA虚拟机-运行时数据区
原文链接:https://gaoyubo.cn/blogs/8ae1f4ca.html 前置 Golang实现JAVA虚拟机-解析class文件 一.运行时数据区概述 JVM学习: JVM-运行时数据 ...
- 【Python】【OpenCV】绘制外接矩形、外接圆
外接矩形.外接圆: 1 import cv2 2 import numpy 3 4 img = cv2.imread('../img/img.png', -1) 5 ret, thresh = cv2 ...
- C#设计模式之享元模式(Flyweight)
using System; using System.Collections; public class Client { public static void Main(string[] args) ...
- 支付宝沙箱支付-zfbsxzf
title: 支付宝沙箱支付 date: 2022-03-03 13:55:15.281 updated: 2022-03-10 16:00:42.331 url: https://www.yby6. ...
- MyBatis 源码解析
本文源码解析针对的是 MyBatis 3.4.4 MyBatis 执行流程 第一阶段 MyBatis 在这个阶段获得 Mapper 的动态代理对象,具体逻辑如下图所示: 其中,Configuratio ...
- CodeForces 1030E Vasya and Good Sequences 位运算 思维
原题链接 题意 目前我们有一个长为n的序列,我们可以对其中的每一个数进行任意的二进制重排(改变其二进制表示结果的排列),问我们进行若干次操作后得到的序列,最多能有多少对 \(l, r\) 使得 \([ ...