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 ...
随机推荐
- Vue2.0 学习 第三组 条件语句
本笔记主要参考菜鸟教程和官方文档编写.1.v-if在div或者之类的dom中使用v-if可以控制是否插入该dom,控制由v-if的true和false决定.如:<div id="app ...
- SpringCloudGateway解决跨域问题
1.跨域问题详情 2.为什么会跨域? 官方定义:https://developer.mozilla.org/zh-CN/docs/Web/HTTP/CORS 怎么出现的? 1.浏览器访问了一个业务 h ...
- 【Python】【OpenCV】边缘检测和创建自定义核
对于使用OpenCV已有的算子,我们还可以自定义卷积核以达到不同的效果. filters.py 1 import cv2 2 import numpy 3 4 """ 定 ...
- xml的语法总结
xml的语法总结
- LLaMA大型语言模型
LLaMA (Large Language Model Meta AI)是Meta公司发布的大型语言模型系列,近日LLaMA种子文件被合并到了GitHub 上,同时一些项目维护者给予了批准,目前该项目 ...
- 中间件是开箱即用的吗?为什么要开发中间件adapter?
本文分享自华为云社区<中间件是开箱即用的吗?为什么要开发中间件adapter?>,作者:张俭. 中间件在很多系统中都存在 在一个系统里面,或多或少地都会有中间件的存在,总会有数据库,其他的 ...
- C++ Qt开发:Charts与数据库组件联动
Qt 是一个跨平台C++图形界面开发库,利用Qt可以快速开发跨平台窗体应用程序,在Qt中我们可以通过拖拽的方式将不同组件放到指定的位置,实现图形化开发极大的方便了开发效率,本章将重点介绍Charts组 ...
- 全网最全的华为ensp数通设备命令全集
[命令] display history-command [视图]所有视图 [参数]无 [描述] display history-command 命令用来显示当 前用户曾键入的最后 10 条命令.用户 ...
- Java中一些常用的方法实现(更新中)
一.数组 1.indexOf int targetIndex = indexOf(arr, targetValue); public static int indexOf(int[] arr,int ...
- java中获取内网IP
package com.dashan.utils.iputils; import org.apache.commons.lang.StringUtils; import javax.servlet.h ...