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. js判断是安卓 还是 ios webview?

    通过判断浏览器的userAgent,用正则来判断是否是ios和Android客户端.代码如下: <script type="text/javascript"> var ...

  2. Python之实例属性和类属性

    参考原文 廖雪峰Python 实例属性和类属性 在前面已经说过由于Python是动态语言,可以根据类的实例绑定任何的属性. 给实例绑定属性的方法是通过实例变量,或者self变量绑定的: class S ...

  3. 攻破javascript面试的完美指南【译】

    攻破javascript面试的完美指南(开发者视角) 0. 前言 本文适合有一定js基础的前端开发人员阅读.原文是我google时无意发现的, 被一些知识点清晰的解析所打动, 决定翻译并记录下来.这个 ...

  4. cc.Node—Action

    1: Action类是动作命令,我们创建Action,然后节点运行action就能够执行Action的动作; 2: Action分为两类: (1) 瞬时就完成的ActionInstant, (2) 要 ...

  5. MarkDown语法和使用

    MarkDown语法: Markdown在线编辑器 MdEditor Markdown 语法整理大集合2017 MarkDown 数学公式 在Markdown中输入数学公式(MathJax) \(\l ...

  6. ZJU cluster

    * loginSSH using MobaXterm: >> ssh kaiming@10.106.239.105

  7. Leetcode 90.子集

    子集 给定一个可能包含重复元素的整数数组 nums,返回该数组所有可能的子集(幂集). 说明:解集不能包含重复的子集. 示例: 输入: [1,2,2] 输出: [ [2], [1], [1,2,2], ...

  8. [BZOJ2120] 数颜色 && [bzoj2453] 维护队列(莫队 || 分块)

    传送门 只有第一个,第二个权限题. 分块,然而wa,没看出来错在哪里,有时间再看. #include <cmath> #include <cstdio> #include &l ...

  9. 如何将jsp后缀重写为html

    公司有时候要写一些小的项目,而用java搭建web的一个缺(特)陷(征)就是动态网页的后缀名.jsp.没办法啊,就是不能以.jsp结尾,原因有几个:隐藏服务端技术:吸引爬虫:对用户更友好:等等.如果全 ...

  10. 将完整的Maven远程存储库下载到本地存储库(别试了,不太可取)

    别试了,这种方式不太可取. 要解决可以有如下思路: 1.做成镜像站点,有如下命令: wget -m http://site.to.mirror.com #-m代表“镜子”. rsync repo1.m ...