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 个占 ...
随机推荐
- 黑马程序员_7K月薪面试题之_交通灯管理系统
----------- android培训.java培训.java学习型技术博客.期待与您交流! --------- 1,交通灯管理系统的项目需求 模拟实现十字路口的交通灯管理系统逻辑,具体需求如下: ...
- [Javascript] Automate the process of flattening deeply nested arrays using ES2019's flat method
Among the features introduced to the language of JavaScript in ES2019 is Array.prototype.flat. In th ...
- Jconsole
Jconsole 1.1 简介以及连接 JConsole是一个基于JMX的GUI工具,用于连接正在运行的JVM,它是Java自带的简单性能监控工具.下面以对tomcat的监控为例,带领大家熟悉Jcon ...
- Java实现二叉树及相关遍历方式
Java实现二叉树及相关遍历方式 在计算机科学中.二叉树是每一个节点最多有两个子树的树结构.通常子树被称作"左子树"(left subtree)和"右子树"(r ...
- Win7如何删除家庭组
发表于 2010-07-15 11:38:06 [YY团]Win7家庭组不能正常使用的解决办法 只是把近期碰到的一个小毛病的解决方案共享一下罢了,估计碰到这问题的人不会很多-- 表现是家庭组不能正常访 ...
- C#时间的味道——任时光匆匆我只在乎你
如果没有遇见你,我将会是在哪里?日子过的怎么样人生是否要珍惜...任时光匆匆我只在乎你,心甘情愿感染你的气息,人生几何能得到知己...一首邓丽君的<我只在乎你>不禁令我唏嘘不已,这些年离我 ...
- POJ2406-Power Strings(kmp循环节)
Power Strings Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 31111 Accepted: 12982 D ...
- Timer使用
1. Timer简介 Timer是jdk中提供的一个定时器工具,使用的时候会在主线程之外起一个单独的线程执行指定的计划任务,可以指定执行一次或者反复执行多次. 通过创建Timer对象,然后调用Time ...
- hiberbnate 缓存策略概述
1. 首先了解什么是缓存 这里说的缓存并不是指计算机的内存或者CPU的一二级缓存. 缓存是指为了降低应用程序对物理数据源访问的频次,从而提高应用程序的运行性能的一种策略.即对物理数据源的复制,存在于内 ...
- LaTeX 图片插入
一般格式: \begin{figure} \centering \includegraphics[scale=0.2]{Figure211.png} \caption{In the case of a ...