hdu 5611 /BC 69B Baby Ming and phone number

19 篇文章 0 订阅

直接按照题面描述模拟即可

对于前两条 可以一起判断 差值是否为1,0,-1

对于日期 年在范围内 并且合法即可

对于2月有29天的闰年的定义为 年份 可以被400整除 或者 不能被100整除但能被4整除


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#define scnaf scanf
#define cahr char
#define bug puts("bugbugbug");
using namespace std;
typedef long long ll;
const int mod=1000000007;
const int maxn=50+5;
const int inf=1e9;
const int maxe=200000;
char cha[100];
int a[100];
bool go()
{
    int nian,yue,ri;
    nian=a[3]*1000+a[4]*100+a[5]*10+a[6];
    yue=a[7]*10+a[8];
    ri=a[9]*10+a[10];
    if(nian<1980||nian>2016) return 0;
    if(yue>=1&&yue<=12); else return 0;
    int maxx=31;
    if(yue==4||yue==6||yue==9||yue==11)
        maxx=30;
    if(yue==2){
        if(nian%400==0||(nian%4==0&&nian%100))
            maxx=29;
        else maxx=28;
    }
    if(ri<0||ri>maxx) return 0;
    return 1;
}
bool ok()
{
    for(int i=0;i<11;i++)
        a[i]=cha[i]-'0';
    if(go()) return 1;
    int v=a[7]-a[6];
    if(abs(v)>1) return 0;
    for(int i=7;i<11;i++)
        if(a[i]-a[i-1]!=v) return 0;
    return 1;
}
int main()
{
    int T_T;
    scanf("%d",&T_T);
    int a,b,n;
    while(T_T--){
        ll ans=0;
        scanf("%d%d%d",&n,&a,&b);
        for(int i=0;i<n;i++){
            scanf("%s",cha);
            if(ok()) ans+=a;
            else ans+=b;
        }
        printf("%I64d\n",ans);
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值