//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的更多相关文章

  1. POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理

    Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798 ...

  2. POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理

    Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   ...

  3. POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286 ...

  4. POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法

    Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Descr ...

  5. POJ 3254. Corn Fields 状态压缩DP (入门级)

    Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 5185 Descr ...

  6. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

  7. POJ 2255. Tree Recovery

    Tree Recovery Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11939   Accepted: 7493 De ...

  8. 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 ...

  9. poj 2352 Stars 数星星 详解

    题目: poj 2352 Stars 数星星 题意:已知n个星星的坐标.每个星星都有一个等级,数值等于坐标系内纵坐标和横坐标皆不大于它的星星的个数.星星的坐标按照纵坐标从小到大的顺序给出,纵坐标相同时 ...

  10. poj 1251 Jungle Roads (最小生成树)

    poj   1251  Jungle Roads  (最小生成树) Link: http://poj.org/problem?id=1251 Jungle Roads Time Limit: 1000 ...

随机推荐

  1. Vue学习笔记-快速入门

    整体代码如下: <!DOCTYPE html> <html lang="en"> <head> <meta charset="U ...

  2. ElasticSearch之cat nodes API

    命令样例如下: curl -X GET "https://localhost:9200/_cat/nodes?v=true&pretty" --cacert $ES_HOM ...

  3. Pikachu漏洞靶场 Burte Force(暴力破解)

    Burte Force(暴力破解) 文章目录 Burte Force(暴力破解) 概述 1.基于表单的暴力破解 2.验证码绕过(on server) 3.验证码绕过(on client) 4.toke ...

  4. Mybatis源码1JDBC->mybatis主要流程->mybatis Excutor简介

    === 一丶mybatis概述 MyBatis 是一款优秀的持久层框架,它支持自定义 SQL.存储过程以及高级映射.MyBatis 免除了几乎所有的 JDBC 代码以及设置参数和获取结果集的工作.My ...

  5. 23、Flutter AppBar TabBar TabBarView

    AppBar自定义顶部按钮图标.颜色 class MyHomePage extends StatelessWidget { const MyHomePage({super.key}); @overri ...

  6. .Net 系列:Attribute特性的高级使用及自定义验证实现

    一.特性是什么?特性有什么用? 特性(Attribute)是用于在运行时传递程序中各种元素(比如类.方法.结构.枚举.组件等)的行为信息的声明性标签. 您可以通过使用特性向程序添加声明性信息.一个声明 ...

  7. Java 在PPT中添加文本、图片超链接

    本文介绍通过Java程序在PPT幻灯片中添加超链接的方法,可以给文本或者图片设置超链接,设置超链接时,可设置包括网页链接.邮件地址链接.幻灯片跳转链接等不同指向对象的链接.文中方法使用了免费版PPT类 ...

  8. 带你认识数仓的监控系统TopSQL

    本文分享自华为云社区<GaussDB(DWS)TopSQL总结>,作者:nullptr_ . TopSQL 背景 TopSQL为DWS的监控系统,记录DWS中各个作业.算子级别的资源使用数 ...

  9. 解读革命性容器集群CCE Turbo:计算、网络、调度全方位加速

    摘要:CCE Turbo是华为云推出的一款革命性容器集群. 5月31日,在华为云Techwave云基础设施技术专题日上,华为云容器批量计算首席架构师马达对CCE Turbo的技术内幕进行了深度解读,C ...

  10. Linux如何进行GPIO读写操作的?

    摘要:本文介绍GPIO的读写,介绍基本原理,以及不同读写方式的性能. 本文分享自华为云社区<Linux 基于sysfs的GPIO读写操作>,作者:一颗小树x . 前言 最近接触到Linux ...