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. ES 提案的各状态

    JavaScrpit,亦即 ECMAScript,新功能的演进是由一个叫 TC39 这么个组织在统筹协调和推进的. 一般新特性会由社区先提案,被采纳后开始进入下一流程.一个提案到最终落地到成为标准,需 ...

  2. scala学习(2)---option空值处理

    https://blog.csdn.net/shadowsama/article/details/78148919 https://www.cnblogs.com/mustone/p/5648914. ...

  3. block相关归纳

    经过今天的Block的学习.上网查询相关文章归纳了一下 一.一个使用Block的好处有: Block可以用在许多不同的环境中,这样可以让代码更加简单,以及减少函数声明的数量,不用实现代理协议. 简单性 ...

  4. extjs动态插入一列

    StdDayWordQuery:function(btn,event){ var form=Ext.getCmp('queryFormSDW'); var userNameORuserCode = f ...

  5. Extjs定时操作

    查看api可知: // 启动一个简单的时钟任务,每秒执行一次更新一个 div var task = { run: function(){ Ext.fly('clock').update(new Dat ...

  6. C++ Primer(第4版)-学习笔记-第3部分:类和数据抽象

    第12章 类       每个类可以没有成员,也可以定义多个成员,成员可以是数据.函数或类型别名. 成员函数必须在类内部声明,可以在类内部定义,也可以在类外部定义.如果在类内部定义,就默认是内联函数. ...

  7. 移动端placeholder不能垂直居中解决方案

    1.问题描述 问题如图:手机端placeholder文字偏上,垂直方向不居中,input光标显示偏上解决IE下不支持placeholder属性 2.解决方案 css .phoneNumber inpu ...

  8. Python-函数和代码复用

    函数的定义与使用 >函数的理解与定义 函数是一段代码的表示 -函数是一段具有特定功能的.可重用的语句组 -函数是一种功能的抽象,一般函数表达特定功能 -两个作用:降低编程难度 和 代码复用 de ...

  9. sql杂记:一些坑和数据库恢复

    这是一篇纯粹的乱七八糟的笔记...(勿喷)主要记录一下初入SQL坑的杂七杂八的注意事项. 一.先补充下事务的写法: start transaction;#开始事务 --各种事务... commit;# ...

  10. HDU - 6446 Tree and Permutation

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6446 本题是一个树上的问题——DFS. 一棵N个结点的树,其结点为1~N.树具有N-1条边,每一条边具有 ...