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中元组与数组的区别
列表: a=['12', '3rr'] 元组: t=(21,34) 列表可以修改,而元组不可以修改,如果元组中仅有一个元素,则要在元素后加上逗号. 元组和列表的查询方式一样. 元组只可读不可修改. 如 ...
- 微信OAuth授权获取用户OpenId-JAVA(个人经验)【申明:来源于网络】
微信OAuth授权获取用户OpenId-JAVA(个人经验)[申明:来源于网络] 地址:https://my.oschina.net/xshuai/blog/293458
- PAT甲级1057 Stack【树状数组】【二分】
题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805417945710592 题意:对一个栈进行push, pop和 ...
- ES6 Map 与 Set
Map 对象 Map 对象保存键值对.任何值(对象或者原始值) 都可以作为一个键或一个值. Maps 和 Objects 的区别 一个 Object 的键只能是字符串或者 Symbols,但一个 Ma ...
- 洛谷P2569 股票交易 [SCOI2010] dp
正解:dp+单调队列优化 解题报告: 先放个传送门鸭qwq umm首先dp转移挺好想的?就买和不买 f[i][j]表示第i天手上有j的股份的最多钱,转移也很好想?就枚举第1天到第i-w-1天枚举买k股 ...
- java框架之SpringMVC(2)-补充及拦截器
高级参数绑定 package com.zze.springmvc.web.controller; import org.springframework.stereotype.Controller; i ...
- VoiceXML标识元素及其属性
VoiceXML 元素 <assign> 给变量赋值. <audio> 播放语音文件. <block> 无用户交互的可执行代码块. <catch> 捕获 ...
- git pull 冲突拉取不到新的代码
本地文件已经有冲突或者在pull的过程中拉取的文件和本地文件冲突时,拉取不到新的代码,git pull出现报错,如下: 这个时候,如果你有两种选择,如果你需要这些改动,那个你就需要手动解决冲突,然后a ...
- js 获取时区
js的时区函数: 设datename为创建的一个Date对象 ====================datename.getTimezoneOffset()--取得当地时间和GMT时间(格林威治时间 ...
- Gitlab安装以及汉化
Gitlab安装以及汉化 系统环境: CentOS 7.5 IP:192.168.1.2 关闭selinux.firewalld gitlab-ce-10.8.4 rpm包:下载地址 一.下载并安装g ...