Total Submission(s): 271 Accepted Submission(s): 86
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.
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)
1≤T≤30,b<1000,0<a,n≤100,000
#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;
}