• HDU 5611 Baby Ming and phone number


    #include<cstdio>
    #include<cstring>
    #include<vector>
    #include<cmath>
    #include<queue>
    #include<list>
    #include<algorithm>
    using namespace std;
    
    int T,n;
    char s[20];
    long long a,b;
    int q1[20],q2[20];
    
    long long f()
    {
        if(s[10]==s[9]&&s[10]==s[8]&&s[10]==s[7]&&s[10]==s[6]) return a;
        bool fail=0;
        for(int i=7;i<=10;i++) if(s[i]-s[i-1]!=1) fail=1;
        if(fail==0) return a;
         fail=0;
        for(int i=7;i<=10;i++) if(s[i]-s[i-1]!=-1) fail=1;
        if(fail==0) return a;
    
        int year=(s[3]-'0')*1000+(s[4]-'0')*100+(s[5]-'0')*10+(s[6]-'0');
        int month=(s[7]-'0')*10+(s[8]-'0');
        int day=(s[9]-'0')*10+(s[10]-'0');
    
        if(year>=1980&&year<=2016)
        {
            if(month>=1&&month<=12)
            {
                if( ((0 == year%4)&&(0 != year%100)) ||(0 == year %400) )
                {
                    if(day>=1&&day<=q2[month]) return a;
                }
                else
                {
                    if(day>=1&&day<=q1[month]) return a;
                }
            }
        }
        return b;
    }
    
    int main()
    {
        q1[1]=31;
        q1[2]=28;
        q1[3]=31;
        q1[4]=30;
        q1[5]=31;
        q1[6]=30;
        q1[7]=31;
        q1[8]=31;
        q1[9]=30;
        q1[10]=31;
        q1[11]=30;
        q1[12]=31;
    
        q2[1]=31;
        q2[2]=29;
        q2[3]=31;
        q2[4]=30;
        q2[5]=31;
        q2[6]=30;
        q2[7]=31;
        q2[8]=31;
        q2[9]=30;
        q2[10]=31;
        q2[11]=30;
        q2[12]=31;
        scanf("%d",&T);
        while(T--)
        {
            scanf("%d",&n);
            scanf("%lld%lld",&a,&b);
            long long ans=0;
            for(int i=1;i<=n;i++)
            {
                scanf("%s",s);
                ans=ans+f();
            }
            printf("%lld
    ",ans);
        }
        return 0;
    }
  • 相关阅读:
    搞明白这八个问题,Linux系统就好学多了
    Fedora 25 Alpha版本今天发布啦
    Linux新手应掌握的10个基本命令
    PC-BSD 换名 TrueOS
    JPA+Springboot实现分页效果
    陈亮
    押尾光太郎
    岸部真明
    面试必备-网络的七层协议
    JavaScript中的快速排序
  • 原文地址:https://www.cnblogs.com/zufezzt/p/5157989.html
Copyright © 2020-2023  润新知