Daylight Saving Time

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Problem Description
Last month, xiaodao together with her friend poteko took a flight from San Francisco to Shanghai.
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”.
 
Input
The first line of the input gives the number of test cases, T.
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.
 
Output
For each test case, first output one line containing “Case #x: ”, where x is the test case number (starting from 1), following a result string which in one of “PST”, “PDT”, “Both” or “Neither”.
∙ 1 ≤ T ≤ 1000.
∙ date will be legal and between “2007-01-01 00:00:00” and “2100-12-31 23:59:59”.
 
Sample Input
4
2016-03-13 01:59:59
2016-03-13 02:00:00
2016-11-06 00:59:59
2016-11-06 01:00:00
 
Sample Output
Case #1: PST
Case #2: Neither
Case #3: PDT
Case #4: Both
 
Source
 

思路:泰勒公式;

#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

Problem Description
Last month, xiaodao together with her friend poteko took a flight from San Francisco to Shanghai.
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”.
 
Input
The first line of the input gives the number of test cases, T.
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.
 
Output
For each test case, first output one line containing “Case #x: ”, where x is the test case number (starting from 1), following a result string which in one of “PST”, “PDT”, “Both” or “Neither”.
∙ 1 ≤ T ≤ 1000.
∙ date will be legal and between “2007-01-01 00:00:00” and “2100-12-31 23:59:59”.
 
Sample Input
4
2016-03-13 01:59:59
2016-03-13 02:00:00
2016-11-06 00:59:59
2016-11-06 01:00:00
 
Sample Output
Case #1: PST
Case #2: Neither
Case #3: PDT
Case #4: Both
 
Source
 

hdu 6010 Daylight Saving Time 泰勒公式的更多相关文章

  1. HDU 6010 - Daylight Saving Time

    先算周几,再模拟 #include <bits/stdc++.h> using namespace std; int GetWeekDay(int y,int m,int d)//0为周一 ...

  2. HDU6010 Daylight Saving Time

    /* HDU6010 Daylight Saving Time http://acm.hdu.edu.cn/showproblem.php?pid=6010 模拟 题意:算当前时间是否是夏令时 */ ...

  3. Daylight Saving Time

    [Daylight Saving Time] 夏时制,又称日光节约时制.日光節約時間(英语:Daylight saving time)或夏令时间(英语:Summer time),是一种为节约能源而人为 ...

  4. hdu 6010 路径交

    hdu 6010 路径交(lca + 线段树) 题意: 给出一棵大小为\(n\)的树和\(m\)条路径,求第\(L\)条路径到第\(R\)条路径的交的路径的长度 思路: 本题的关键就是求路径交 假设存 ...

  5. DayLight Saving Light(HDU6010)

    传送门:DayLight Saving Light 夏令时: 夏时令(Daylight Saving Time:DST),又称“日光节约时制”和“夏令时间”,是一种为节约能源而人为规定地方时间的制度, ...

  6. HDU 5025:Saving Tang Monk(BFS + 状压)

    http://acm.hdu.edu.cn/showproblem.php?pid=5025 Saving Tang Monk Problem Description   <Journey to ...

  7. HDU 4308 BFS Saving Princess claire_

    原题直通车:HDU 4308 Saving Princess claire_ 分析: 两次BFS分别找出‘Y’.‘C’到达最近的‘P’的最小消耗.再算出‘Y’到‘C’的最小消耗,比较出最小值 代码: ...

  8. HDU 2111:Saving HDU(贪心)

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  9. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

随机推荐

  1. 搭建svn服务器的坑

    第一次搭建,能启动,就是连接不了 原因:修改配置文件(所有文字前面不能有空格,等号必须空格)

  2. 队列模拟基本操作I

    看到这道题,第一个想法就是“搜索”!“回溯”!的确,这种思路是很正确的,BFS和DFS都可以来解决: #include <cstdlib> #include <cstring> ...

  3. java之Spring集成CXF简单调用

    简介 Apache CXF = Celtix + XFire,开始叫 Apache CeltiXfire,后来更名为 Apache CXF 了,以下简称为 CXF.CXF 继承了 Celtix 和 X ...

  4. python基础之 while 逻辑运算符 格式化输出等

    1.while循环 while 条件: 循环体 while 条件: 循环体 else: 循环体 重点: 当条件为真的时候,就进入循环体,从上到下依次执行,执行完最后一条语句时,while并不是直接退出 ...

  5. eclipse添加spring boot 插件

    在使用eclipse开发时,一般需要添加spring boot的管理插件,这样更方便我们开发,在写application.yml或properties配置的时候,也有相关的提示,而且还可以从配置文件中 ...

  6. Applet程序组件与AJAX技术

    Applet 定义 Applet是一种运行于Web客户端环境下的Java程序组件. 工作原理 Applet以代码的形式嵌入Web页面中,用标签<applet></applet> ...

  7. 日期计算、正则、sequence、索引、表连接、mybatis

    ************************** mybatis ******************************************* #{} 的参数替换是发生在 DBMS 中, ...

  8. Sci_DRead_ParaBuzzerDriver_st_BuzzerSoundOpening1

    extern uint16 Sci_DRead_ParaMotorGroupB_u16_Motor1CinchDoneCurrent1(); * \violation 1503 The functio ...

  9. flutter_webview_plugin 无法加载网页的异常处理

    Flutter 本身并未集成webview,所以当需要使用webview 的时候,使用flutter_webview_plugin插件,也就是使用的原生webview组件, flutter_webvi ...

  10. php 去除变态空格字符方法,空格trim不掉问题解决思路

    前言:今天过滤一段文本,后面有2个空格,用trim去不掉,用preg_match也去不掉,去网上翻阅了无数的方法,终于找到了非常好的一个解决方法.该文章来源于https://my.oschina.ne ...