BestCoder Round #69 (div.2)(hdu5611)

Baby Ming and phone number

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

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)

1≤T≤30,b<1000,0<a,n≤100,000

Output

How much Baby Nero can earn.

Sample Input

1

5

100000 1000

12319990212

11111111111

22222223456

10022221111

32165491212

Sample Output

302000

分步判断是否符合题意即可   休要细心,代码未ac  还有细节未处理好  先记录下来

#include<stdio.h>
#include<string.h>
#include<string>
#include<math.h>
#include<algorithm>
#define LL long long
#define PI atan(1.0)*4
#define DD doublea
#define MAX 100100
#define mod 10007
using namespace std;
int s[MAX][15];
char s1[MAX][15];
int op1[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int op2[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
int five(int x)//判断后五位
{
	int i,j;
	char y=s[x][6];
	int flag=1;
	for(i=7;i<11;i++)
	{
		if(s[x][i]!=y)
		{
			flag=0;
			break;
		}
	}
	if(flag==1) return 1;
	flag=1;
	for(i=7;i<11;i++)
	{
		if(s[x][i]!=s[x][i-1]+1)
		{
			flag=0;
			break;
		}
	}
	if(flag==1) return 1;
	else return 0;
}
int judge(int x)//判断闰年
{
	if((x%4==0&&x%100!=0)||x%400==0)
	    return 1;
	else return 0;
}
int eight(int x)  //判断后八位
{
	int i,j;
	int flag=1;
	int sum=s[x][3];
	int mouth=s[x][7]*10+s[x][8];
	int day=s[x][9]*10+s[x][10];
	for(i=4;i<=6;i++)
 	   sum=sum*10+s[x][i];
 	if(sum<1980||sum>2016||mouth<1||mouth>12)
 	    return 0;
 	if(sum==1980)
 	{
 		if(mouth<7||mouth>12)
 		    return 0;
 	    if(day==0||day>op1[mouth])
 	        return 0;
 	}
 	if(judge(sum))
 	{
 	    if(day==0||day>op2[mouth])
 	        return 0;
 	}
 	if(!judge(sum))
 	{
 		if(day==0||day>op1[mouth])
 	        return 0;
 	}
 	return 1;
}
int main()
{
    int t,i,j,n,m;
    LL ans,a,b;
	scanf("%d",&t);
	while(t--)
	{
		ans=0;
		scanf("%d",&n);
		scanf("%lld%lld",&a,&b);
		for(i=1;i<=n;i++)
		{
			scanf("%s",s1[i]);
			for(j=0;j<11;j++)
			{
				s[i][j]=s1[i][j]-‘0‘;
			}
		}
		for(i=1;i<=n;i++)
		{
			if(five(i))
				ans+=a;
			else if(eight(i))
				ans+=a;
			else ans+=b;
		}
		printf("%lld\n",ans);
	}
	return 0;
}

  

时间: 2024-10-10 12:04:48

BestCoder Round #69 (div.2)(hdu5611)的相关文章

BestCoder Round #69 (div.2) Baby Ming and Weight lifting(hdu 5610)

Baby Ming and Weight lifting Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 681    Accepted Submission(s): 280 Problem Description Baby Ming is fond of weight lifting. He has a barbell pole(the

Codeforces Round #259 (Div. 2) (序列)

题目链接:http://codeforces.com/contest/454/problem/B B. Little Pony and Sort by Shift time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output One day, Twilight Sparkle is interested in how to sort a se

Codeforces Round #306 (Div. 2) (构造)

A. Two Substrings 题意:给一个字符串,求是否含有不重叠的子串"AB"和"BA",长度1e5. 题解:看起来很简单,但是一直错,各种考虑不周全,最后只能很蠢的暴力,把所有的AB和BA的位置求出来,能有一对AB和BA不重叠即可. 1 #include <bits/stdc++.h> 2 using namespace std; 3 4 char a[100005]; 5 vector<int> ab; 6 vector<i

题解Codeforces Round #595 (Div. 3)(CF1249)

开题1小时(雾)严重影响我的提交以及做题心情..我刚开题就发现有人阿克了.. 实际上这场div3真心简单良心很休闲. A:送分题,先排序,每次枚举一下这个数可以加到哪个集合里,加进去就行. 1 #include<stdio.h> 2 #include<algorithm> 3 #define it register int 4 #define il inline 5 using namespace std; 6 const int N=1000005; 7 int a[N],o[N

Codeforces Round #616 (Div. 2) (A-D)

A. Even But Not Even 仔细分析一下题意,可以发现只和奇数的个数有关: 然后分情况讨论: 1.奇数的个数是奇数 2.奇数的个数是偶数 3.奇数的个数为0 #include <iostream> #include <algorithm> #include <string> #include <string.h> #include <vector> #include <map> #include <stack>

BestCoder Round #77 (div.2)(hdu5650,hdu5651(逆元),hdu5652(二分),hdu5653(dp))

so easy 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5650 解题思路: 中文题目: 问题描述 已知一个包含 nn 个元素的正整数集合 SS,设 f(S)f(S) 为集合 SS 中所有元素的异或(XOR)的结果. 如:S = \{1, 2, 3\}S={1,2,3}, 则 f(S) = 0f(S)=0. 给出集合 SS,你需要计算 将所有 f(s)f(s) 进行异或后的值, 这里 s \subseteq Ss?S. 输入描述 多组测试数

BestCoder Round #73 (div.2)(hdu 5630)

Rikka with Chess Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 177    Accepted Submission(s): 161 Problem Description Yuta gives Rikka a chess board of size n×m. As we all know, on a chess boa

BestCoder Round #71 (div.2) (hdu 5620 菲波那切数列变形)

KK's Steel Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 350    Accepted Submission(s): 166 Problem Description Our lovely KK has a difficult mathematical problem:he has a N(1≤N≤1018) meters s

Codeforces Round #604 (Div. 2)(A-E)

A. Beautiful String 题意:把'?'换成'a' or 'b' or 'c'使得相邻的两个字符不相同. 暴力枚举每个'?'前后. #include <bits/stdc++.h> using namespace std; const int MAXN=1e5+10; string s; int main(){ ios::sync_with_stdio(false); int T; cin>>T; while(T--){ cin>>s; bool ok=t