/**
题目: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)只给了后两位数,问有多少种合法的排列使时间正确。的更多相关文章

  1. 2016 Asia Jakarta Regional Contest A - Confusing Date Format UVALive 7711 【模拟题】

    A - Confusing Date Format 题目大意:就是有六种日期格式,给你一个字符串,判断它能组成多少种可能的日期. 第一次WA是:1.没有判重,2.没有特判题目要求的数据,3.判断天数时 ...

  2. js Date format(日期格式化:yyyy-MM-dd HH:mm:ss.S)

    今天在做日期显示的时候,那个显示格式困扰了很久,各种组件都尝试了,总是不如意,最后自己网上找了一个,然后稍微修改一下,感觉这个Util挺常用的,这里mark一下 Date.prototype.form ...

  3. javascript Date format(js日期格式化) (转)

    方法一:这个很不错,好像是 csdn 的 Meizz 写的: // 对Date的扩展,将 Date 转化为指定格式的String // 月(M).日(d).小时(h).分(m).秒(s).季度(q) ...

  4. [转]javascript Date format(js日期格式化)

    方法一:这个很不错,好像是 csdn 的 Meizz 写的: // 对Date的扩展,将 Date 转化为指定格式的String // 月(M).日(d).小时(h).分(m).秒(s).季度(q)  ...

  5. javascript Date format(js日期格式化)

    这个用这比较爽,记录一下// 对Date的扩展,将 Date 转化为指定格式的String // 月(M).日(d).小时(h).分(m).秒(s).季度(q) 可以用 1-2 个占位符, // 年( ...

  6. [荐]javascript Date format(js日期格式化)

    cnblog:http://www.cnblogs.com/zhangpengshou/archive/2012/07/19/2599053.html 方法一: // 对Date的扩展,将 Date  ...

  7. JS Date.Format

    // 对Date的扩展,将 Date 转化为指定格式的String // 月(M).日(d).小时(h).分(m).秒(s).季度(q) 可以用 1-2 个占位符, // 年(y)可以用 1-4 个占 ...

  8. Javascript Date Format

    // 对Date的扩展,将 Date 转化为指定格式的String // 月(M).日(d).小时(h).分(m).秒(s).季度(q) 可以用 1-2 个占位符, // 年(y)可以用 1-4 个占 ...

  9. Date Format, 时间戳格式化

    // 对Date的扩展,将 Date 转化为指定格式的String // 月(M).日(d).小时(h).分(m).秒(s).季度(q) 可以用 1-2 个占位符, // 年(y)可以用 1-4 个占 ...

随机推荐

  1. Python自然语言处理资料库

    1.LTP [1]- 语言技术平台(LTP) 提供包括中文分词.词性标注.命名实体识别.依存句法分析.语义角色标注等丰富. 高效.精准的自然语言处理技术.经过哈工大社会计算与信息检索研究中心 11 年 ...

  2. Spring框架学习(10)Spring中如何使用事务?

    内容源自:Spring中如何使用事务? 一.为什么要使用事务? 如果我们一个业务逻辑只执行一次sql,是不需要使用事务的.但如果要执行多条sql语句才能完成一个业务逻辑的话,这个时候就要使用事务了. ...

  3. PHP基础知识(一)

    The Basics Comparison operators Comparison operators are an often overlooked aspect of PHP, which ca ...

  4. Git学习笔记一--创建版本库、添加文件、提交文件等

    Git,是Linus花了两周时间用C写的一个分布式版本控制系统.牛该怎么定义? 其实,很多人都不care谁写了Git,只在乎它是免费而且好用的!So do I! 下面开始我们的学习: 1.Git安装( ...

  5. IBM-ETP 实训项目前一天

    明天就要开始项目了,实训项目,虽然之前做了几个项目,但是明天就要被一个有着8年项目经验的大牛带着做这个项目了.心中还是不免有点兴奋的.希望能学到更多的东西,来充实自己. 自己也搭建了一个小的demo ...

  6. Spring中AOP的理解

    1.AOP的概念 AOP(AspectOriented Programming,面向切面编程)指的是可以通过预编译方式和运行期动态代理实现在不修改源代码的情况下个程序动态统一添加功能的一种技术.AOP ...

  7. 用filter:grayscale将图片过滤成灰色

    设置成百分之百直接过滤成灰色: img{filter:gray; filter:grayscale(100%); -0-filter:grayscale(100%); -moz-filter:gray ...

  8. Sublime Text 如何一个代码双屏显示代码上下部分?

    Sublime Text 如何一个代码双屏显示代码上下部分? sublime text如何一个代码双屏显示代码上下部分 先显示2行实图 把想要分屏显示的文件,打开新窗口,然后再拖过去就可以了. 快捷操 ...

  9. Tomcat 监控的几种方法

    Tomcat 监控方法 方法1:.使用tomcat自带的status页 具体方法: 步骤1:修改%tomcat安装路径%\conf \tomcat-users文件,配置admin设置权限.在<t ...

  10. 忽略警告注解@SuppressWarnings详解

    简介:java.lang.SuppressWarnings是J2SE 5.0中标准的Annotation之一.可以标注在类.字段.方法.参数.构造方法,以及局部变量上. 作用:告诉编译器忽略指定的警告 ...