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 ...
随机推荐
- 【笔记】Python3导入包规则
例如:这里给出了一种可能的包结构(在分层的文件系统中): sound/ 顶层包 __init__.py 初始化 sound 包 formats/ 文件格式转换子包 __init__.py wavrea ...
- ngVerify - 更高效的 angular 表单验证
ngVerify v1.5.0 a easy Angular Form Validation plugin.简洁高效的__angular表单验证插件__ See how powerful it.看看它 ...
- What every computer science major should know 每一个计算机科学专业的毕业生都应该都知道的
Given the expansive growth in the field, it's become challenging to discern what belongs in a modern ...
- win7使用经验-调整cmd窗口大小
分享一个调整cmd窗口的方法: 1.右击标题栏空白处,选择属性 2.选择布局栏 3.修改屏幕缓冲区大小的宽度和高度(自定义) 4.确定 注意:这里的缓冲区大小是指用户可拖动缩放的范围,并不是cmd窗口 ...
- ubuntu 12.4,搞定apt源
http://wiki.ubuntu.org.cn/Template:12.04source deb http://cn.archive.ubuntu.com/ubuntu/ precise main ...
- 贝叶斯--旧金山犯罪分类预测和电影评价好坏 demo
来源引用:https://blog.csdn.net/han_xiaoyang/article/details/50629608 1.引言 贝叶斯是经典的机器学习算法,朴素贝叶斯经常运用于机器学习的案 ...
- Javascript面向对象编程(四):非构造函数的继承
什么叫非构造函数的继承? 比如,现在有一个对象,叫做"中国人". var Chinese = { nation:'中国' }; 还有一个对象,叫做"医生". v ...
- 学习笔记(3)---安装SVM问题及解决方法
1. LibSVM下载,安装 下载地址:http://www.csie.ntu.edu.tw/~cjlin/libsvm/,最新的版本是3.17 2. 入门 [heart_scale_label,he ...
- 2019-1-29-Sublime-Text-安装中文、英文字体
title author date CreateTime categories Sublime Text 安装中文.英文字体 lindexi 2019-01-29 16:35:25 +0800 201 ...
- 【风马一族_php】数组函数
原文来自:http://www.cnblogs.com/sows/p/6045699.html (博客园的)风马一族 侵犯版本,后果自负 2016-11-09 15:56:26 数组 函数 php- ...