2016 Asia Jakarta Regional Contest A - Confusing Date Format UVALive 7711 【模拟题】
题目大意:就是有六种日期格式,给你一个字符串,判断它能组成多少种可能的日期。
第一次WA是:1.没有判重,2.没有特判题目要求的数据,3.判断天数时少了一个c(天数)>0的条件
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
char s[];
int aa, bb, cc;
int cu[]; bool runnian(int n)
{
if (((n % == ) && (n % != )) || (n % == && n % == ))
return true;
return false;
} int tianshu(int a)
{
if (a == ) return ;
else if (a == || a == || a == || a == ) return ;
else return ;
} bool YMD(int a, int b, int c)
{
if (runnian(a)) {
if (b == ) {
if (c>&&c <= ) {
return true;
}
else {
return false;
}
}
else {
if (b> && b <= && b != && c> && c <= tianshu(b)) return true;
else return false;
}
}
else
{
if (b> && b <= ) {
if (c> && c <= tianshu(b)) return true;
return false;
}
else return false;
} return false;
} int shu(int a, int b, int c)
{
return a * + b * + c;
} int main()
{
int T;
scanf("%d", &T);
for (int cas = ; cas <= T; cas++)
{
scanf("%s", s);
int a, b, c;
a = (s[] - '') * + (s[] - '');
b = (s[] - '') * + (s[] - '');
c = (s[] - '') * + (s[] - ''); int ans = ;
int nu = ;
if (YMD(a + , b, c)) { cu[nu++] = shu(a, b, c), ans++; }
if (YMD(a + , c, b)) { cu[nu++] = shu(a, c, b), ans++; }
if (YMD(b + , a, c)) { cu[nu++] = shu(b, a, c), ans++; }
if (YMD(b + , c, a)) { cu[nu++] = shu(b, c, a), ans++; }
if (YMD(c + , b, a)) { cu[nu++] = shu(c, b, a), ans++; }
if (YMD(c + , a, b)) { cu[nu++] = shu(c, a, b), ans++; } sort(cu, cu + nu);
int tot = ;
int tmp = cu[];
for (int i = ; i<nu; i++) {
if (cu[i] != tmp) tot++;
tmp = cu[i];
} if (a == && b == && c == ) tot = ;
if (ans == ) tot = ;
printf("Case #%d: %d\n", cas, tot);
}
return ;
}
再贴一份学长写的优秀代码:
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<iostream>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<algorithm>
typedef long long ll;
const int maxn = 3e3 + ;
const int INF = 1e3 + ;
using namespace std; int month[] = {,,,,,,,,,,,,};
struct P {
int Y, M, D;
P() {}
P(int y, int m, int d) : Y(y), M(m), D(d) {}
bool operator < (P p) const {
if(Y != p.Y) return Y < p.Y;
if(M != p.M) return M < p.M;
return D < p.D;
}
bool right() {
if(Y % == || (Y % == && Y % != )) month[] = ;
else month[] = ;
if(Y < || Y > ) return false;
if(M < || M > ) return false;
if(D < || D > month[M]) return false;
return true;
}
};
int n, T, kase = ;
int y, m, d; int main() {
scanf("%d", &T);
while(T--) {
scanf("%d-%d-%d", &y, &m, &d);
if(y == && m == && d == ) {
printf("Case #%d: %d\n", kase++, );
continue;
}
set<P> st;
if(P(+y, m, d).right()) st.insert(P(+y, m, d));
if(P(+y, d, m).right()) st.insert(P(+y, d, m));
if(P(+m, y, d).right()) st.insert(P(+m, y, d));
if(P(+m, d, y).right()) st.insert(P(+m, d, y));
if(P(+d, m, y).right()) st.insert(P(+d, m, y));
if(P(+d, y, m).right()) st.insert(P(+d, y, m));
printf("Case #%d: %d\n", kase++, st.size());
}
return ;
}
2016 Asia Jakarta Regional Contest A - Confusing Date Format UVALive 7711 【模拟题】的更多相关文章
- Confusing Date Format UVALive 7711 给定mm-mm-mm格式的时间。年份(1900-1999)只给了后两位数,问有多少种合法的排列使时间正确。
/** 题目:Confusing Date Format UVALive 7711 链接:https://vjudge.net/contest/174844#problem/A 题意:给定mm-mm- ...
- 2016 Asia Jakarta Regional Contest L - Tale of a Happy Man UVALive - 7722
UVALive - 7722 一定要自己做出来!
- 2016 Asia Jakarta Regional Contest J - Super Sum UVALive - 7720 【快速幂+逆元】
J-Super Sum 题目大意就是给定N个三元组<a,b,c>求Σ(a1^k1*a2^k2*...*ai^ki*..an^kn)(bi<=ki<=ci) 唉.其实题目本身不难 ...
- 2019-2020 ICPC, Asia Jakarta Regional Contest (Online Mirror, ICPC Rules, Teams Preferred)
2019-2020 ICPC, Asia Jakarta Regional Contest (Online Mirror, ICPC Rules, Teams Preferred) easy: ACE ...
- 2019-2020 ICPC, Asia Jakarta Regional Contest
目录 Contest Info Solutions A. Copying Homework C. Even Path E. Songwriter G. Performance Review H. Tw ...
- 2019-2020 ICPC, Asia Jakarta Regional Contest H. Twin Buildings
As you might already know, space has always been a problem in ICPC Jakarta. To cope with this, ICPC ...
- 2018 ICPC Asia Jakarta Regional Contest
题目传送门 题号 A B C D E F G H I J K L 状态 Ο . . Ο . . Ø Ø Ø Ø . Ο Ο:当场 Ø:已补 . : 待补 A. Edit Distance Thin ...
- Asia Jakarta Regional Contest 2019 I - Mission Possible
cf的地址 因为校强, "咕咕十段"队获得了EC-final的参赛资格 因为我弱, "咕咕十段"队现在银面很大 于是咕咕十段决定进行训练. 周末vp了一场, 这 ...
- 2019-2020 ICPC, Asia Jakarta Regional Contest C. Even Path
Pathfinding is a task of finding a route between two points. It often appears in many problems. For ...
随机推荐
- Leetcode151. Reverse Words in a String翻转字符串里的单词
给定一个字符串,逐个翻转字符串中的每个单词. 示例: 输入: "the sky is blue", 输出: "blue is sky the". 说明: 无空格 ...
- Web App开发注意事项
1.首先我们来看看webkit内核中的一些私有的meta标签,这些meta标签在开发webapp时起到非常重要的作用 <meta content=”width=device-width, ini ...
- ACMer之歌
<<死了都要编>> 死了都要编 不动态规划不痛快 算法多深只有这样 才足够表白 死了都要编 不A星算法不痛快 宇宙毁灭星还在 把每天当成是比赛来编程 一分一秒都编到汗水掉下来 ...
- CI框架--URL路径跳转与传值
CI框架使用URL的前提是需要加载辅助函数$this->load->helper('url');当然我建议大家将所有需要加载的东西写在构造方法内,这样就不需每个控制器每个方法都去调用一次了 ...
- Python之路,Day3- Python基础(转载Alex)
本节内容 1. 函数基本语法及特性 2. 参数与局部变量 3. 返回值 嵌套函数 4.递归 5.匿名函数 6.函数式编程介绍 7.高阶函数 8.内置函数 温故知新 1. 集合 主要作用: 去重 关系测 ...
- Asio与Boost.Asio
译自http://think-async.com/Asio/AsioAndBoostAsio Asio有两种变体:(非Boost)Asio和Boost.Asio.本文概要描述二者的不同. 1. 源代码 ...
- Binder对象死亡通知机制
本文參考<Android系统源码情景分析>,作者罗升阳. 一.Binder库(libbinder)代码: ~/Android/frameworks/base/libs/bin ...
- 计蒜客 Flashing Fluorescents(状压DP)
You have nn lights, each with its own button, in a line. Pressing a light’s button will toggle that ...
- 洛谷P1474 [USACO 2.3]货币系统 Money Systems [2017年4月计划 动态规划04]
P1474 货币系统 Money Systems 题目描述 母牛们不但创建了它们自己的政府而且选择了建立了自己的货币系统.由于它们特殊的思考方式,它们对货币的数值感到好奇. 传统地,一个货币系统是由1 ...
- Django项目:CRM(客户关系管理系统)--16--08PerfectCRM实现King_admin显示注册表的字段表头
# king_urls.py # ————————02PerfectCRM创建ADMIN页面———————— from django.conf.urls import url from king_ad ...