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.
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)
1≤T≤30,b<1000,0<a,n≤100,000
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
Output
How much Baby Nero can earn.
Sample Input
1 5 100000 1000 12319990212 11111111111 22222223456 10022221111 32165491212
Sample Output
302000
只是判断年月日时注意一下,闰年,月份对应的天数就可以了
#include<cstdio>
#include<cstring>
int main(){
int t;
int n, dx, dy, dz;
long long a, b, sum;
char str[15];
scanf("%d", &t);
while(t--){
scanf("%d", &n);
scanf("%I64d%I64d", &a, &b);
sum = 0;
for(int i =0; i < n; i ++){
scanf("%s", str);
if(str[10]==str[9]&&str[9]==str[8]&&str[8]==str[7]&&str[7]==str[6]) sum+=a;
else if(str[10]-str[9]==1&&str[9]-str[8]==1&&str[8]-str[7]==1&&str[7]-str[6]==1) sum+=a;
else if(str[10]-str[9]==-1&&str[9]-str[8]==-1&&str[8]-str[7]==-1&&str[7]-str[6]==-1) sum+=a;
else {
dx = (str[3]-'0')*1000+(str[4]-'0')*100+(str[5]-'0')*10+str[6]-'0';
dy = (str[7]-'0')*10+str[8]-'0';
dz = (str[9]-'0')*10+str[10]-'0';
if(dx>=1980&&dx<=2016&&dy>0&&dy<=12){
if(dy==1||dy==3||dy==5||dy==7||dy==8||dy==10||dy==12){
if(dz>0&&dz<=31) sum += a;
else sum += b;
}
else if(dy==2){
if((dx%100!=0&&dx%4==0)||(dx%400==0)) {
if(dz>0&&dz<=29) sum += a;
else sum += b;
}
else {
if(dz>0&&dz<=28) sum += a;
else sum += b;
}
}
else {
if(dz>0&&dz<=30) sum+=a;
else sum +=b;
}
}
else sum += b;
}
}
printf("%I64d\n", sum);
}
return 0;
}