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 ...
随机推荐
- Leetcode504.Base 7七进制数
给定一个整数,将其转化为7进制,并以字符串形式输出. 示例 1: 输入: 100 输出: "202" 示例 2: 输入: -7 输出: "-10" 注意: 输入 ...
- 技术人自己的KPI
为什么需要技术KPI 在业务技术团队,有一个不好的趋势,就是团队越来越业务,越来越没有技术味道.每个人都在谈业务,技术大会上在谈业务,周会上在聊业务,周报里写的是业务项目......唯独少被谈及的是技 ...
- 读书笔记--iBATIS in Action 目录
1.iBATIS的理念 2.iBATIS是什么 3.安装和配置iBATIS 4.使用以映射语句 5.执行非查询语句 6.使用高级查询技术 7.事务 8.使用动态SQL 9.使用高速缓存提高性能 10. ...
- HDU4578 Transformation (多操作线段树)
传送门 终于过了这道题.. 要注意标记之间的影响,和add操作时更新求和的顺序. same 区间每个数设置为x标记 mult 区间每个数乘x标记 add 区间每个数加x标记 ①:当打same标记时 ...
- 采坑“微信小程序”
1.微信小程序变量定义时中间不能使用 “-”. 2.padding值不能为负.
- datetime模块常用函数
import datetime import time # 当前时间戳 now = time.time() print(now) # 时间戳转换成时间元祖 now = time.localtime(n ...
- python对dataframe的相关用法
1.选择列名包含特殊字符的列 d2 = d1.loc[:, d1.columns.str.contains('vib')] 2.选择列名开头为包含特殊字符的列 df2 = df1.loc[:, df1 ...
- pip list报错:DEPRECATION: The default format will switch to columns in the future.
一.现象: pip list 显示出以下错误: DEPRECATION: The default format will switch to columns in the future. Yo ...
- PHP 学习1.1
1 链接mysql 数据简单测试 <html><head> <title></title> <meta http-equiv="Co ...
- hdu 2087剪花布条 (KMP入门 子串出现的次数和子串个数)
剪花布条 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...