hdu 6010 Daylight Saving Time 泰勒公式
Daylight Saving Time
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
When they were driving to the airport, xiaodao suddenly realized that the clock time on potekos car is one hour faster than the clock time on her mobile phone. And both of them might be correct, but how can it be? Because that day was Nov 6th, the Daylight saving time switch day this year.
Daylight saving time (DST) or summer time is the practice of advancing clocks during summer months by one hour so that evening daylight lasts an hour longer. It is arguable that using DST can reduce overall energy consumption. Not all of us are using DST now, and for those regions adopting DST, the practices are also different.
In the case of California, effective in the U.S. in 2007 as a result of the Energy Policy Act of 2005, the local time changes from Pacific Standard Time (PST) to Pacific Daylight Time (PDT) at 02:00 to 03:00 on the second Sunday in March and the local time changes back from PDT to PST at 02:00 to 01:00 on the first Sunday in November.
Because it is one hour longer on that day, so xiaodao and poteko didn’t miss the flights, but they found it still a little confusing. Interestingly, once xiaodao went back to Shanghai, she met a bug caused by exactly the same issue during the work. You might also be in trouble with DST some day, so here comes this problem and hope it will be helpful.
The local time in California without specifying whether it is PST or PDT could be ambiguous in some cases (e.g. 2016-11-06 01:25:00). In this problem, you are given a local time in California.
Check whether it is “PST”, “PDT”, “Both” or “Neither”.
T test cases follow. Each test case consists of one line, a date string written in the following format: YYYY-MM-DD HH:MM:SS.
∙ 1 ≤ T ≤ 1000.
∙ date will be legal and between “2007-01-01 00:00:00” and “2100-12-31 23:59:59”.
2016-03-13 01:59:59
2016-03-13 02:00:00
2016-11-06 00:59:59
2016-11-06 01:00:00
Case #2: Neither
Case #3: PDT
Case #4: Both
思路:泰勒公式;
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<queue>
#include<algorithm>
#include<stack>
#include<cstring>
#include<vector>
#include<list>
#include<bitset>
#include<set>
#include<map>
#include<time.h>
using namespace std;
#define LL long long
#define bug(x) cout<<"bug"<<x<<endl;
const int N=1e2+,M=2e6+,inf=1e9+;
const LL INF=1e18+,mod=,MOD=;
const double eps=1e-,pi=(*atan(1.0)); int Change(int year,int month,int day)
{
if(month==||month==)
{
month+=;
year--;
}
int c=year/;
int y=year%;
int m=month;
int d=day;
int W=c/-*c+y+y/+*(m+)/+d-;
if(W<)
return (W+(-W/+)*)%;
return W%;
}
int main()
{
int T,cas=;
scanf("%d",&T);
while(T--)
{
int y,m,d,h,mi,s;
scanf("%d-%d-%d %d:%d:%d",&y,&m,&d,&h,&mi,&s);
printf("Case #%d: ",cas++);
int flag=,ans1=-,ans2=-;
for(int i=;;i++)
{
if(Change(y,m,i)==)
{
flag++;
if(flag==)ans1=i;
else ans2=i;
if(flag==)break;
}
}
if(m==)
{
if(d<ans2)printf("PST\n");
else if(d>ans2)printf("PDT\n");
else
{
if(h==)printf("Neither\n");
else if(h<)printf("PST\n");
else printf("PDT\n");
}
}
else if(m==)
{
if(d<ans1)printf("PDT\n");
else if(d>ans1)printf("PST\n");
else
{
if(h==)printf("Both\n");
else if(h>)printf("PST\n");
else printf("PDT\n");
}
}
else if(m>&&m<)printf("PDT\n");
else printf("PST\n");
}
return ;
}
Daylight Saving Time
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 279 Accepted Submission(s): 142
When they were driving to the airport, xiaodao suddenly realized that the clock time on potekos car is one hour faster than the clock time on her mobile phone. And both of them might be correct, but how can it be? Because that day was Nov 6th, the Daylight saving time switch day this year.
Daylight saving time (DST) or summer time is the practice of advancing clocks during summer months by one hour so that evening daylight lasts an hour longer. It is arguable that using DST can reduce overall energy consumption. Not all of us are using DST now, and for those regions adopting DST, the practices are also different.
In the case of California, effective in the U.S. in 2007 as a result of the Energy Policy Act of 2005, the local time changes from Pacific Standard Time (PST) to Pacific Daylight Time (PDT) at 02:00 to 03:00 on the second Sunday in March and the local time changes back from PDT to PST at 02:00 to 01:00 on the first Sunday in November.
Because it is one hour longer on that day, so xiaodao and poteko didn’t miss the flights, but they found it still a little confusing. Interestingly, once xiaodao went back to Shanghai, she met a bug caused by exactly the same issue during the work. You might also be in trouble with DST some day, so here comes this problem and hope it will be helpful.
The local time in California without specifying whether it is PST or PDT could be ambiguous in some cases (e.g. 2016-11-06 01:25:00). In this problem, you are given a local time in California.
Check whether it is “PST”, “PDT”, “Both” or “Neither”.
T test cases follow. Each test case consists of one line, a date string written in the following format: YYYY-MM-DD HH:MM:SS.
∙ 1 ≤ T ≤ 1000.
∙ date will be legal and between “2007-01-01 00:00:00” and “2100-12-31 23:59:59”.
2016-03-13 01:59:59
2016-03-13 02:00:00
2016-11-06 00:59:59
2016-11-06 01:00:00
Case #2: Neither
Case #3: PDT
Case #4: Both
hdu 6010 Daylight Saving Time 泰勒公式的更多相关文章
- HDU 6010 - Daylight Saving Time
先算周几,再模拟 #include <bits/stdc++.h> using namespace std; int GetWeekDay(int y,int m,int d)//0为周一 ...
- HDU6010 Daylight Saving Time
/* HDU6010 Daylight Saving Time http://acm.hdu.edu.cn/showproblem.php?pid=6010 模拟 题意:算当前时间是否是夏令时 */ ...
- Daylight Saving Time
[Daylight Saving Time] 夏时制,又称日光节约时制.日光節約時間(英语:Daylight saving time)或夏令时间(英语:Summer time),是一种为节约能源而人为 ...
- hdu 6010 路径交
hdu 6010 路径交(lca + 线段树) 题意: 给出一棵大小为\(n\)的树和\(m\)条路径,求第\(L\)条路径到第\(R\)条路径的交的路径的长度 思路: 本题的关键就是求路径交 假设存 ...
- DayLight Saving Light(HDU6010)
传送门:DayLight Saving Light 夏令时: 夏时令(Daylight Saving Time:DST),又称“日光节约时制”和“夏令时间”,是一种为节约能源而人为规定地方时间的制度, ...
- HDU 5025:Saving Tang Monk(BFS + 状压)
http://acm.hdu.edu.cn/showproblem.php?pid=5025 Saving Tang Monk Problem Description <Journey to ...
- HDU 4308 BFS Saving Princess claire_
原题直通车:HDU 4308 Saving Princess claire_ 分析: 两次BFS分别找出‘Y’.‘C’到达最近的‘P’的最小消耗.再算出‘Y’到‘C’的最小消耗,比较出最小值 代码: ...
- HDU 2111:Saving HDU(贪心)
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
随机推荐
- Python学习之旅(二十一)
Python基础知识(20):错误.调试和测试 一.错误处理 在运行程序的过程中有可能会出错,一般我们会在添加一段代码在可能出错的地方,返回约定的值,就可以知道会不会出错以及出错的原因 1.使用try ...
- 用户场景分析i
名字 学生(注重饮食选择,挑剔) 年龄 20 收入 无 知识层面 大学 使用这个网站的典型场景 中午或者晚上饿了但是不知道想吃什么,又不想随便吃,还是比较挑剔..这时,他就需要通过我们的网站来看其他人 ...
- python练习题-day9
2.写函数,检查获取传入列表或元组对象的所有奇数位索引对应的元素,并将其作为新列表返回给调用者. def dan_index(itter): li=[] for i in range(len(itte ...
- git忽略规则.gitignore未生效解决办法
创建git本地的仓库常用命令:git init #初始化--------生成.git文件 配置本地用户名跟邮箱(这样就知道是谁提交的东西)git config --global user.name [ ...
- Creator仿超级玛丽小游戏源码分享
Creator仿超级玛丽小游戏源码分享 之前用Cocos Creator 做的一款仿超级玛丽的游戏,使用的版本为14.2 ,可以直接打包为APK,现在毕设已经完成,游戏分享出来,大家一起学习进步.特别 ...
- Servlet Analysis
@WebServlet("/cdiservlet") //url映射 public class NewServlet extends HttpServlet { private M ...
- 屏幕适配(UGUI)非UI
using UnityEngine; public enum Suit_UIType { Background, Effect, } [RequireComponent(typeof(Transfor ...
- Oracle数据库管理----性能优化
https://blog.csdn.net/yzllz001/article/details/54848513 数据库访问优化法则 要正确的优化SQL,我们需要快速定位能性的瓶颈点,也就是说快速找 ...
- myBatis学习之路1-基本功能实现
myBatis也是一个持久型框架,相较于hibernate来说,算是轻量级的. 1.配置mybatis环境 相关jar下载地址:mybatis+mysalJAR包 2.新建一个java project ...
- 用javaScript对页面元素进行显示和隐藏
将显示元素进行隐藏 用document.getElementById("ID名").hidden=ture;根据页面元素ID名获得页面元素值,进而将其属性设置成隐藏. 将隐藏元素进 ...