Baby Ming and phone number

Crawling in process...
Crawling failed
Time Limit:1500MS    
Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

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)




$1 \leq T \leq 30, b < 1000, 0 < a, n \leq 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>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
cin>>n;
char str[1010];
__int64 ans=0;
__int64 a,b;
scanf("%lld%lld",&a,&b);
for(int i=0;i<n;i++)
{
memset(str,'\0',sizeof(str));
bool f=false;
scanf("%s",str);
for(int i=0;i<11;i++)
str[i]-='0';
if(str[10]==str[9]&&str[10]==str[8]&&str[10]==str[7]&&str[10]==str[6])
f=true;
else if(str[6]+1==str[7]&&str[7]+1==str[8]&&str[8]+1==str[9]&&str[9]+1==str[10])
f=true;
else if(str[6]-1==str[7]&&str[7]-1==str[8]&&str[8]-1==str[9]&&str[9]-1==str[10])
f=true;
int year=str[3]*1000+str[4]*100+str[5]*10+str[6];
int mon=str[7]*10+str[8];
int day=str[9]*10+str[10];
if(year>=1980&&year<=2016)
{
if(mon==1||mon==3||mon==5||mon==7||mon==8||mon==10||mon==12)
{
if(day<=31)
f=true;
}
if(mon==4||mon==6||mon==9||mon==11)
{
if(day<=30)
f=true;
}
if(mon==2&&day<=28)
f=true;
if((year%4==0&&year%100!=0)||year%400==0)
if(mon==2&&day==29)
f=true;
}
if(f)
ans+=a;
else
ans+=b;
}
printf("%lld\n",ans);
}
return 0;
}

 

hdoj--5611--Baby Ming and phone number(模拟水题)的更多相关文章

  1. hdu 5611 Baby Ming and phone number(模拟)

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

  2. HDU 5611 Baby Ming and phone number

    #include<cstdio> #include<cstring> #include<vector> #include<cmath> #include ...

  3. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  4. POJ 2014:Flow Layout 模拟水题

    Flow Layout Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 3091   Accepted: 2148 Descr ...

  5. hdu 1018:Big Number(水题)

    Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

  6. Codeforces Round #350 (Div. 2) F. Restore a Number 模拟构造题

    F. Restore a Number   Vasya decided to pass a very large integer n to Kate. First, he wrote that num ...

  7. HDOJ 1008. Elevator 简单模拟水题

    Elevator Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Su ...

  8. CodeForces 689A Mike and Cellphone (模拟+水题)

    Mike and Cellphone 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/E Description While sw ...

  9. UVA 10714 Ants 蚂蚁 贪心+模拟 水题

    题意:蚂蚁在木棍上爬,速度1cm/s,给出木棍长度和每只蚂蚁的位置,问蚂蚁全部下木棍的最长时间和最短时间. 模拟一下,发现其实灰常水的贪心... 不能直接求最大和最小的= =.只要求出每只蚂蚁都走长路 ...

随机推荐

  1. Could not resolve type alias 'map '. Cause: java.lang.ClassNotFoundException: Cannot find class: map

    把resultType改为resultMap, 把parameterType改为parameterMap,重新发布并运行.

  2. oracle 安装准备

    1.选择数据库 (官网查询支持的操作系统) 2.选择系统 (官网查询支持的硬件)(更新补丁) 3.选择硬件 (io性能测试--oracle 大量小文件读写) 4.oracle 升级(和打补丁) 5.o ...

  3. tf idf公式及sklearn中TfidfVectorizer

    在文本挖掘预处理之向量化与Hash Trick中我们讲到在文本挖掘的预处理中,向量化之后一般都伴随着TF-IDF的处理,那么什么是TF-IDF,为什么一般我们要加这一步预处理呢?这里就对TF-IDF的 ...

  4. gson序列化后整形变浮点问题解决方案

    字段值是json格式的字符串.我需要将这个字段反序列化为List<Map>形式,但是在反序列化后,id变为了1.0. 百度了很多然并卵,最后改用了阿里的fastjson,没问题.(jack ...

  5. P1048 采药

    题目描述 辰辰是个天资聪颖的孩子,他的梦想是成为世界上最伟大的医师.为此,他想拜附近最有威望的医师为师.医师为了判断他的资质,给他出了一个难题.医师把他带到一个到处都是草药的山洞里对他说:“孩子,这个 ...

  6. POJ3616 Milking Time【dp】

    Description Bessie is such a hard-working cow. In fact, she is so focused on maximizing her producti ...

  7. 【eclipse】外部 jar 包导入教程

    JavaWeb 项目中,可以直接将要导入的 jar 程序包复制到你项目下的 WEB-INF/lib 文件夹下,将来程序移动到别的机子上测试时也能正常运行.如果是普通 Java 工程的话,我们可以在项目 ...

  8. Linux设置history命令显示行数以及时间

    Linux和unix上都提供了history命令,可以查询以前执行的命令历史记录但是,这个记录并不包含时间项目因此只能看到命令,但是不知道什么时间执行的如何让history记录时间呢? 解决方案 注意 ...

  9. 求数组差/交集函数-php数组函数(二)

    求数组差集函数 函数只检查了多维数组中的一维.可以用 array_diff($array1[0], $array2[0]) 检查更深的维度. u:自定义函数比较,a(association):同时比较 ...

  10. 虚拟机上CentOS-6.9-x86_64系统安装教程

    最近想学学Linux系统如何使用,于是想用VM安装虚拟机学习一下. linux系统比较多,我这里用的是CentOS-6.9-x86_64 一.下载系统 下载地址:https://www.centos. ...