hdoj 5611 Baby Ming and phone number 【模拟】

Baby Ming and phone number

Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 22    Accepted Submission(s): 9


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.
 

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)

1T30,b<1000,0<a,n100,000
 

Output
How much Baby Nero can earn.
 

Sample Input
  
  
1 5 100000 1000 12319990212 11111111111 22222223456 10022221111 32165491212
 

Sample Output
  
  
302000
 


自己是个大SB。本来十几分钟1A的题目,用了%lld,哭死。第二次了。

题意:

问题描述
铭宝宝收集了很多手机号码,没错,他想卖手机号码赚钱。
他觉得有如下性质的手机号码可以卖aa元钱,其他的号码,只能卖bb元钱。
1.末5位数字相同(比如123-4567-7777)
2.末5位是连续递增或者连续递减的,且相邻数位相差1的数(比如188-0002-3456)
3.末8位是一个表示日期的数字,并且表示的日期在1980年1月1日至2016年12月31日内(比如188-1888-0809表示1888年8月9日)
铭宝宝想知道卖掉所有的手机号码能赚多少钱。
输入描述
输入T(T \leq 30)T(T30)表示TT组测试数据
输入n(n \leq 100,000)n(n100,000)表示铭宝宝有nn张手机号码(没有相同的手机号码)
输入22个正整数a, ba,b, 表示两种类型的手机号码分别能卖aa元和bb(b \leq 1000, a \leq 100,000)(b1000,a100,000)
接下去nn行,每行输入11个手机号码(|phonenumber|==11,首位非0)
输出描述
输出答案
输入样例
1
5
100000 1000
12319990212
11111111111
22222223456
10022221111
32165491212
输出样例
302000

AC代码:


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <string>
#define INF 0x3f3f3f3f
#define eps 1e-8
#define MAXN (1000+10)
#define MAXM (200000+10)
#define Ri(a) scanf("%d", &a)
#define Rl(a) scanf("%lld", &a)
#define Rf(a) scanf("%lf", &a)
#define Rs(a) scanf("%s", a)
#define Pi(a) printf("%d\n", (a))
#define Pf(a) printf("%.2lf\n", (a))
#define Pl(a) printf("%lld\n", (a))
#define Ps(a) printf("%s\n", (a))
#define W(a) while((a)--)
#define CLR(a, b) memset(a, (b), sizeof(a))
#define MOD 1000000007
#define LL long long
#define lson o<<1, l, mid
#define rson o<<1|1, mid+1, r
#define ll o<<1
#define rr o<<1|1
#define PI acos(-1.0)
using namespace std;
int D[13] = {0, 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool judge(int y){
    return y % 400 == 0 || (y % 4 == 0 && y % 100);
}
char str[13];
int main()
{
    int t; Ri(t);
    W(t)
    {
        int n; Ri(n);
        LL a, b;
        Rl(a); Rl(b);
        LL ans = 0;
        W(n)
        {
            Rs(str);
            char op = str[6];
            bool flag = true;
            for(int i = 7; i < 11; i++)
            {
                if(str[i] != op)
                {
                    flag = false;
                    break;
                }
            }
            if(flag) {ans += a; continue;}
            flag = true;
            for(int i = 7; i < 11; i++)
            {
                int x = str[i] - '0';
                int y = str[i-1] - '0';
                if(x != y + 1)
                {
                    flag = false;
                    break;
                }
            }
            if(flag) {ans += a; continue;}
            flag = true;
            for(int i = 7; i < 11; i++)
            {
                int x = str[i] - '0';
                int y = str[i-1] - '0';
                if(x != y - 1)
                {
                    flag = false;
                    break;
                }
            }
            if(flag) {ans += a; continue;}
            int year = 0, month = 0, day = 0;
            for(int i = 3; i <= 6; i++)
                year = year * 10 + (str[i] - '0');
            month = (str[7] - '0') * 10 + str[8] - '0';
            day = (str[9] - '0') * 10 + str[10] - '0';
            if(judge(year)) D[2] = 29;
            else D[2] = 28;
            if(year >= 1980 && year <= 2016 && month >= 1 && month <= 12 && day >= 1 && day <= D[month])
                ans += a;
            else ans += b;
        }
        printf("%I64d\n", ans);
    }
    return 0;
}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值