hdu 6010 Daylight Saving Time 泰勒公式

时间:2022-09-23 18:23:32

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&lpar;HDU6010&rpar;

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

  6. HDU 5025:Saving Tang Monk(BFS &plus; 状压)

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

  7. HDU 4308 BFS Saving Princess claire&lowbar;

    原题直通车: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. jQuery组件系列:封装标签页(Tabs)

    我自己封装的组件,你也行,静态链接地址 http://www.cnblogs.com/leee/p/5190489.html 声明.最好,先把代码拷过去运行一下,其实特别丑~再往下看 我没优化,因为我 ...

  2. 未在本地计算机上注册&OpenCurlyDoubleQuote;Microsoft&period;ACE&period;OLEDB&period;12&period;0”提供程序。

    笔记本装的是windows 7旗舰版64位系统,使用的是MS Office 2007(Microsoft.ACE.OLEDB.12.0,32位程序),开发用的是Visual Studio 2010,我 ...

  3. EditPlus64的安装配置

    下载地址,直接到360下载即可,下载完毕之后,进入如下网址,完后在线生成注册码 http://www.jb51.net/tools/editplus/ 以上是文本编辑器EditPlus的安装以及注册, ...

  4. 【解决】Oracle服务器ip地址被占用

    数据库服务器ip地址被占用,怎么破?! 服务器: 1.改服务器ip: 2.改tnsnames.ora里配置的Oracle数据库ip: 3.重启Oracle服务: 客户端: 1.改tnsnames.or ...

  5. java 循环制作三角形

    package hello; public class Sanjiao { public static void main(String[]args){ for(int i=1;i<5;i++) ...

  6. web压力测试-pylot

    我已经写在使用前Web Bench做压力測试.http://blog.csdn.net/jacson_bai/article/details/41143713 但这个測试,測试结果非常好.缺点就是,无 ...

  7. JAVA进阶5

    间歇性混吃等死,持续性踌躇满志系列-------------第5天 1.IDEA常用快捷键 2.简单方法的使用 package cn.intcast.day05.demo01; public clas ...

  8. js函数集

    js函数集·字符串(String) 1.声明 var myString = new String("Every good boy does fine."); var myStrin ...

  9. Linux 创建用户并赋予 Sudo 权限

    01,创建账号 => useradd admin 02,赋予密码 => passwd admin 03,修改 sudo 权限文件,使得该用户可以使用 sudo 命令 vim /etc/su ...

  10. Maven update project&period;&period;&period;后jdk变成1&period;5,update project后jdk版本改变

    Maven update project...后jdk变成1.5,update project后jdk版本改变 ============================== 蕃薯耀 2018年3月14 ...