Baby Ming and phone number
Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 222 Accepted Submission(s): 68
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.
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
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
题意:
思路:直接模拟就行了,只是注意月份和日期的判断,还有结果会爆int
ac代码:
302000
题意:
铭宝宝收集了很多手机号码,没错,他想卖手机号码赚钱。
他觉得有如下性质的手机号码可以卖a元钱,其他的号码,只能卖b元钱。
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日)
铭宝宝想知道卖掉所有的手机号码能赚多少钱。
思路:直接模拟就行了,只是注意月份和日期的判断,还有结果会爆int
ac代码:
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stack>
#include<set>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
#define MAXN 1010000
#define LL long long
#define ll __int64
#define INF 0xfffffff
#define mem(x) memset(x,0,sizeof(x))
#define PI acos(-1)
using namespace std;
char str[15];
int s[15];
int m[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int check(int a,int b,int c)
{
if(a<1980||a>2016)
return 0;
if(b<1||b>12)
return 0;
if(c<1||c>31)
return 0;
if(a%400==0||(a%4==0&&a%100!=0))
{
if(b==2)
{
if(c<=29)
return 1;
else
return 0;
}
else
{
if(c>m[b])
return 0;
else
return 1;
}
}
else
{
if(b==2)
{
if(c<=28)
return 1;
else
return 0;
}
else
{
if(c>m[b])
return 0;
else
return 1;
}
}
}
int main()
{
int t,a,b,c;
int i,j,n;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
scanf("%d%d",&a,&b);
ll ans=0;
while(n--)
{
scanf("%s",str);
int len=strlen(str);
for(i=0;i<len;i++)
s[i]=str[i]-'0';
int bz=0;
if(s[10]==s[9]&&s[9]==s[8]&&s[8]==s[7]&&s[7]==s[6])
ans+=a,bz=1;
//printf("bz=%d\n",bz);
if(((s[10]>s[9]&&s[9]>s[8]&&s[8]>s[7]&&s[7]>s[6])||(s[10]<s[9]&&s[9]<s[8]&&s[8]<s[7]&&s[7]<s[6]))&&bz==0)
{
if(abs(s[10]-s[9])==1&&abs(s[9]-s[8])==1&&abs(s[8]-s[7])==1&&abs(s[7]-s[6])==1)
ans+=a,bz=1;
}
//printf("bz=%d\n",bz);
int year=s[3]*1000+s[4]*100+s[5]*10+s[6];
int month=s[7]*10+s[8];
int day=s[9]*10+s[10];
//printf("y=%d m=%d d=%d\n",year,month,day);
if(check(year,month,day)&&bz==0)
ans+=a,bz=1;
if(bz==0)
ans+=b;
}
printf("%I64d\n",ans);
}
return 0;
}