Confusing Date Format UVALive 7711 给定mm-mm-mm格式的时间。年份(1900-1999)只给了后两位数,问有多少种合法的排列使时间正确。
/**
题目:Confusing Date Format UVALive 7711
链接:https://vjudge.net/contest/174844#problem/A
题意:给定mm-mm-mm格式的时间。年份(1900-1999)只给了后两位数,问有多少种合法的排列使时间正确。
思路: 第一次:快速读题,题意不清,没注意到这句话, To punish teams who did not read this problem statement carefully, we’ll add one trick input: if the
input is “
04-05-01
”, the output should be 1 (not 6). 第二次:闰年判断写错了, 错的:if(y%4==0&&(y%100!=0||y%400==0)) 对的:if((y%4==0&&y%100!=0)||y%400==0) 。 第三次:没有判重,假设输入的数字是04-04-04,那么交换位置后,year,month,day会多次出现1904-04-04. */ #include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
using namespace std;
typedef pair<int,int> P;
typedef long long LL;
const int N = 3e5+;
const int mod = 1e9+;
const int INF = 0x3f3f3f3f;
int f[][][];
bool ryear(int y)
{
if((y%==&&y%!=)||y%==){
return true;
}
return false;
}
int judge(int year,int month,int day)
{
if(f[year][month][day]) return ;
f[year][month][day] = ;
year += ;
if(year>=||year<) return ;
if(month==||month==||month==||month==||month==||month==||month==){
if(day>=&&day<=) return ;
else return ;
}
if(month==||month==||month==||month==){
if(day>=&&day<=) return ;
else return ;
}
if(month==){
if(ryear(year)){
if(day>=&&day<=) return ;
return ;
}else
{
if(day>=&&day<=) return ;
return ;
}
}
return ;
}
int main(void)
{
int T;
int cas = ;
cin>>T;
int x, y, z;
while(T--)
{
scanf("%d-%d-%d",&x,&y,&z);
if(x==&&y==&&z==){
printf("Case #%d: %d\n",cas++,); continue;
}
memset(f, , sizeof f);
int ans = ;
ans += judge(x,y,z);
ans += judge(x,z,y);
ans += judge(y,x,z);
ans += judge(y,z,x);
ans += judge(z,x,y);
ans += judge(z,y,x);
printf("Case #%d: %d\n",cas++,ans);
}
return ;
}
Confusing Date Format UVALive 7711 给定mm-mm-mm格式的时间。年份(1900-1999)只给了后两位数,问有多少种合法的排列使时间正确。的更多相关文章
- 2016 Asia Jakarta Regional Contest A - Confusing Date Format UVALive 7711 【模拟题】
A - Confusing Date Format 题目大意:就是有六种日期格式,给你一个字符串,判断它能组成多少种可能的日期. 第一次WA是:1.没有判重,2.没有特判题目要求的数据,3.判断天数时 ...
- js Date format(日期格式化:yyyy-MM-dd HH:mm:ss.S)
今天在做日期显示的时候,那个显示格式困扰了很久,各种组件都尝试了,总是不如意,最后自己网上找了一个,然后稍微修改一下,感觉这个Util挺常用的,这里mark一下 Date.prototype.form ...
- javascript Date format(js日期格式化) (转)
方法一:这个很不错,好像是 csdn 的 Meizz 写的: // 对Date的扩展,将 Date 转化为指定格式的String // 月(M).日(d).小时(h).分(m).秒(s).季度(q) ...
- [转]javascript Date format(js日期格式化)
方法一:这个很不错,好像是 csdn 的 Meizz 写的: // 对Date的扩展,将 Date 转化为指定格式的String // 月(M).日(d).小时(h).分(m).秒(s).季度(q) ...
- javascript Date format(js日期格式化)
这个用这比较爽,记录一下// 对Date的扩展,将 Date 转化为指定格式的String // 月(M).日(d).小时(h).分(m).秒(s).季度(q) 可以用 1-2 个占位符, // 年( ...
- [荐]javascript Date format(js日期格式化)
cnblog:http://www.cnblogs.com/zhangpengshou/archive/2012/07/19/2599053.html 方法一: // 对Date的扩展,将 Date ...
- JS Date.Format
// 对Date的扩展,将 Date 转化为指定格式的String // 月(M).日(d).小时(h).分(m).秒(s).季度(q) 可以用 1-2 个占位符, // 年(y)可以用 1-4 个占 ...
- Javascript Date Format
// 对Date的扩展,将 Date 转化为指定格式的String // 月(M).日(d).小时(h).分(m).秒(s).季度(q) 可以用 1-2 个占位符, // 年(y)可以用 1-4 个占 ...
- Date Format, 时间戳格式化
// 对Date的扩展,将 Date 转化为指定格式的String // 月(M).日(d).小时(h).分(m).秒(s).季度(q) 可以用 1-2 个占位符, // 年(y)可以用 1-4 个占 ...
随机推荐
- NDK下IPC问题
由于AllJoyn的join session timeout问题一直无法解决,我们怀疑AllJoyn有些内部变量没有清理干净,因此考虑将AllJoyn相关功能放到一个单独的进程中,一旦join ses ...
- Java经典算法汇总之冒泡排序
冒泡排序基本思想:在要排序的一组数中,对当前还未排好序的范围内的全部数,自上而下对相邻的两个数依次进行比较和调整,让较大的数往下沉,较小的往上冒.即:每当两相邻的数比较后发现它们的排序与排序要求相反时 ...
- HDU-2665-Kth number(划分树)
Problem Description Give you a sequence and ask you the kth big number of a inteval. Input The fir ...
- Python 类变量 实例变量
类变量: 是可在类的所有实例之间共享的值(也就是说,它们不是单独分配给每个实例的).例如下例中,num_of_instance 就是类变量,用于跟踪存在着多少个Test 的实例. 实例变量: 实例 ...
- 解决tomcat提交的数据乱码的问题
有时,开发过程中会遇到前端传入“中文”并返回时,会出现乱码!主要是因为前端通过tomcat7提交的数据就出现了乱码的问题,也就说根源在于tomcat7. 有2中方案解决该问题: (1)使用tomcat ...
- Direcshow中视频捕捉和參数设置报告
Direcshow中视频捕捉和參数设置报告 1. 关于视频捕捉(About Video Capture in Dshow) 1视频捕捉Graph的构建 一个能够捕捉音频或者视频的graph图 ...
- Android NDK学习记录(一)
一.NDK环境在Mac中部署 1.准备eclipse,android sdk安装包,android ndk安装包(http://dl.google.com/android/ndk/android-nd ...
- Thread.sleep(0)的作用
我们可能经常会用到 Thread.Sleep 函数来使线程挂起一段时间.那么你有没有正确的理解这个函数的用法呢?思考下面这两个问题: 假设现在是 2008-4-7 12:00:00.000,如果我调用 ...
- IT痴汉的工作现状36-做好准备再上路
软件开发流程管理是採用瀑布式好还是敏捷好? 如今非常多人会选择敏捷.由于眼下的现状是需求的变化是一天一个样,这是当前(移动)互联网的飞速发展所带来的.当我们仍採用原始的先做全盘的计划.然后在按部就班的 ...
- 体验了把做HR的感觉,上午看了40份简历,说说感受
原文链接:http://huachichi.info/2013/06/26/experience-of-being-a-hr/ 这两天准备从IBM离职,不要问我为什么要在这么bug的时间离职,总之 ...