zoukankan      html  css  js  c++  java
  • 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;
    }
  • 相关阅读:
    在Wince下使用钩子函数
    WinCE下钩子应用(一)——WinCE 下实时捕获键盘消息
    记录此刻
    常用数列
    百度之星度度熊拼三角
    笛卡尔定理
    Lucas定理
    简单概念
    Unknown Treasure Lucas+中国剩余定理+快速乘
    2017ccpc杭州站 Problem B. Master of Phi
  • 原文地址:https://www.cnblogs.com/zufezzt/p/5157989.html
Copyright © 2011-2022 走看看