Baby Ming and phone number Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 271    Accepted Submission(s): 86


Problem Description
Baby Ming collected lots of cell phone numbers, and he wants to sell them for money.

He thinks normal number can be sold for b yuan, while number with following features can be sold for a yuan.

1.The last five numbers are the same. (such as 123-4567-7777)

2.The last five numbers are successive increasing or decreasing, and the diffidence between two adjacent digits is 1 . (such as 188-0002-3456)

3.The last eight numbers are a date number, the date of which is between Jar 1st, 1980 and Dec 31th, 2016. (such as 188-1888-0809,means August ninth,1888)

Baby Ming wants to know how much he can earn if he sells all the numbers.

Input
In the first line contains a single positive integer T , indicating number of test case.

In the second line there is a positive integer n , which means how many numbers Baby Ming has.(no two same phone number)

In the third line there are 2 positive integers a,b , which means two kinds of phone number can sell a yuan and b yuan.

In the next n lines there are n cell phone numbers.(|phone number|==11, the first number can’t be 0)

1T30,b<1000,0<a,n100,000

Output
How much Baby Nero can earn.

Sample Input
1 5 100000 1000 12319990212 11111111111 22222223456 10022221111 32165491212

Sample Output
302000
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define ll long long 
#define N 100010
using namespace std;
char s[12];
int judge(int y)
{
	if(y%4==0&&y%100!=0||y%400==0)
		return 1;
	return 0;
}
int j1(char *s)
{
	int i,j;
	char x=s[6];
	for(i=7;i<=10;i++)
	{
		if(s[i]!=x)
			return 0;
	}
	return 1;
}
int j2(char *s)
{
	int i,j;
	for(i=7;i<=10;i++)
	{
		if(s[i]-1!=s[i-1])
			return 0;
	}
	return 1;
}
int j3(char *s)
{
	int i,j;
	for(i=7;i<=10;i++)
	{
		if(s[i]+1!=s[i-1])
			return 0;
	}
	return 1;
}
int j4(char *s)
{
	int i,j;
	int y=0,m=0,d=0;
	for(i=3;i<=6;i++)
		y=y*10+s[i]-'0';
	for(i=7;i<=8;i++)
		m=m*10+s[i]-'0';
	for(i=9;i<=10;i++)
		d=d*10+s[i]-'0';
	if(y<1980||y>2016||m>12||d>31||m==0||d==0)//少判断了月份和天数为0的情况,重判时就被踢了,所以还是要细心 
		return 0;
	else
	{
		if((m==4||m==6||m==9||m==11)&&d==31)
			return 0;
		if(m==2&&d>29)
			return 0;
		if(m==2&&!judge(y)&&d==29)
			return 0;
	}
	return 1;
}
int main()
{
	int i,j,k,l;
	int t;
	ll n,a,b;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%lld",&n);
		scanf("%lld%lld",&a,&b);
		getchar();
		ll cnt=0;
		for(i=0;i<n;i++)
		{
			scanf("%s",s);
			if(j1(s))
				cnt++;
			else if(j2(s))
				cnt++;
			else if(j3(s))
				cnt++;
			else if(j4(s))
				cnt++;
		}
		printf("%lld\n",(cnt*a)+(n-cnt)*b);
	}
	return 0;
}