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\n",ans);
    }
    return 0;
}
时间: 2024-08-05 08:45:05

HDU 5611 Baby Ming and phone number的相关文章

HDU 5610 Baby Ming and Weight lifting

Baby Ming and Weight lifting Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1365    Accepted Submission(s): 500 Problem Description Baby Ming is fond of weight lifting. He has a barbell pole(th

HDU 5610 Baby Ming and Weight lifting 暴力

Problem Description Baby Ming is fond of weight lifting. He has a barbell pole(the weight of which can be ignored) and two different kinds of barbell disks(the weight of which are respectively a and b), the amount of each one being infinite.Baby Ming

HDU 5610 Baby Ming and Weight lifting(枚举)

Baby Ming and Weight lifting Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1439    Accepted Submission(s): 525 Problem Description Baby Ming is fond of weight lifting. He has a barbell pole(t

HDU 5612 Baby Ming and Matrix games

暴力搜索,据说精度卡的紧...但我是double过了的. #include<cstdio> #include<cstring> #include<vector> #include<cmath> #include<queue> #include<list> #include<algorithm> using namespace std; const double eps=1e-8; int dir[4][2],t[4][2]

BestCoder Round #69 (div.2) Baby Ming and Weight lifting(hdu 5610)

Baby Ming and Weight lifting Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 681    Accepted Submission(s): 280 Problem Description Baby Ming is fond of weight lifting. He has a barbell pole(the

hdu5612 Baby Ming and Matrix games (dfs加暴力)

Baby Ming and Matrix games Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 849    Accepted Submission(s): 211 Problem Description These few days, Baby Ming is addicted to playing a matrix game.

HDU 4349 Xiao Ming&#39;s Hope 找规律

原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=4349 Xiao Ming's Hope Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1723    Accepted Submission(s): 1144 Problem Description Xiao Ming likes coun

Baby Ming and Matrix games(dfs计算表达式)

Baby Ming and Matrix games Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1210    Accepted Submission(s): 316 Problem Description These few days, Baby Ming is addicted to playing a matrix game

hdu 4349 Xiao Ming&#39;s Hope 规律

Xiao Ming's Hope Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description Xiao Ming likes counting numbers very much, especially he is fond of counting odd numbers. Maybe he thinks it is the best way to