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 ...
随机推荐
- [Array]414. Third Maximum Number
Given a non-empty array of integers, return the third maximum number in this array. If it does not e ...
- LINQ(语言集成查询)
LINQ,语言集成查询(Language Integrated Query)是一组用于c#和Visual Basic语言的扩展.它允许编写C#或者Visual Basic代码以查询数据库相同的方式操作 ...
- windows 标准错误重定向
最近在windows上运行tensorflow的时候,出现很多stderr 的信息,干扰了正常的输出:所以我们需要使用操作把这些输出屏蔽: 参考链接:https://support.microsoft ...
- 玩转Spring Boot 自定义配置、导入XML配置与外部化配置
玩转Spring Boot 自定义配置.导入XML配置与外部化配置 在这里我会全面介绍在Spring Boot里面如何自定义配置,更改Spring Boot默认的配置,以及介绍各配置的优先 ...
- 数据库设计 ch.7
数据库建设的基本规律 三分技术 七分管理 十二分基础数据 阶段 需求分析阶段 概念设计阶段 逻辑设计阶段 物理设计阶段 数据库实施阶段 数据库维护阶段 1 需求分析 2 概念设计 形成概念模型 3 逻 ...
- Lua报unexpected symbol near错误
如果Lua脚本没有错误,那可能是UTF8 BOM的问题
- 计蒜客 Flashing Fluorescents(状压DP)
You have nn lights, each with its own button, in a line. Pressing a light’s button will toggle that ...
- 洛谷P1650 赛马[2017年5月计划 清北学堂51精英班Day1]
P1650 赛马 题目描述 我国历史上有个著名的故事: 那是在2300年以前.齐国的大将军田忌喜欢赛马.他经常和齐王赛马.他和齐王都有三匹马:常规马,上级马,超级马.一共赛三局,每局的胜者可以从负者这 ...
- 关于background-image调整大小和位置的方法笔记
遇到background-image的问题有点多,直接上网搜资料自己整理一下 <!DOCTYPE html> <html lang="en"> <he ...
- Excel怎么增加撤销操作的次数?Excel增加可撤销次数教程
Excel怎么增加撤销操作的次数?Excel增加可撤销次数教程 在Excel的使用中,返回上一步是经常用到的一个工具,当数据填写有误需要查看之前的内容时,一般会通过"Ctrl Z" ...