hdu 5611 Baby Ming and phone number(模拟)

时间:2023-03-08 16:28:21
hdu 5611 Baby Ming and phone number(模拟)
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.

.The last five numbers are the same. (such as --)

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

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

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  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|==, the first number can’t be )

≤T≤,b<,<a,n≤,
Output
How much Baby Nero can earn.
Sample Input

Sample Output

Source

判断日期的时候比较麻烦,也懒得去优化了,还有会爆int,这个值得注意

 #pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<stdlib.h>
#include <stack>
using namespace std;
#define PI acos(-1.0)
#define max(a,b) (a) > (b) ? (a) : (b)
#define min(a,b) (a) < (b) ? (a) : (b)
#define ll long long
#define eps 1e-10
#define MOD 1000000007
#define N 100006
#define inf 1e12
ll n,a,b;
char s[];
bool judge(char *s){
ll a=s[]-'';
ll b=s[]-'';
ll c=s[]-'';
ll d=s[]-'';
ll e=s[]-'';
if( (a==b+) && (b==c+) && (c==d+) && (d==e+) ) return true;
if( (a==b-) && (b==c-) && (c==d-) && (d==e-) ) return true;
return false;
}
bool riqi(ll month,ll day){
if(month == ){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}
}
bool riqi2(ll month,ll day){
if(month< || month>) return false;
if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}
}
bool riqi3(ll month,ll day){
if(month< || month>) return false;
if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}else if(month==){
if(day< || day>) return false;
return true;
}
} bool cal(char *s){
ll year = , month = , day = ;
year = (s[]-'')* + (s[]-'')* + (s[]-'')* +s[]-'';
month = (s[]-'')* + s[]-'';
day = (s[]-'') * + s[]-'';
if(year == ){
if(month> || month<) return false;
if(month==){
if(day< || day>) return false;
return true;
}else if(month == ){
if(day > || day < ) return false;
return true;
}else{
if(riqi(month,day)) return true;
return false;
}
}else if(year == ){
if(riqi2(month,day)) return true;
return false;
}else if(year> && year<){
if((year%==&&year%!=)||(year%==)){
if(riqi2(month,day)) return true;
return false;
}else{
if(riqi3(month,day)) return true;
return false;
}
}else{
return false;
}
} int main()
{
ll t;
scanf("%I64d",&t);
while(t--){
scanf("%I64d",&n);
scanf("%I64d%I64d",&a,&b);
ll ans=;
for(ll i=;i<n;i++){
scanf("%s",s);
if((s[]==s[]) && (s[]==s[]) && (s[]==s[]) && s[]==s[] ){
ans+=a;
}else if(judge(s)){
ans+=a;
}else if(cal(s)){
ans+=a;
}else{
ans+=b;
}
}
printf("%I64d\n",ans);
}
return ;
}