Baby Ming and phone number
Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1681 Accepted Submission(s): 440
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代码:#include<stdio.h> #include<string.h> #include<iostream> #include<algorithm> using namespace std; #define N 100001 int data[14]={0,31,28,31,30,31,30,31,31,30,31,30,31}; char a[N][14]; int T,n; __int64 price1,price2; int main() { int i,j; scanf("%d",&T); while(T--) { __int64 count=0; scanf("%d%I64d%I64d",&n,&price1,&price2); getchar(); for(i=0;i<n;i++) { int t1=0,t2=0; int mark1=1,mark2=1,mark3=0,mark4=1; gets(a[i]); for(j=0;j<11;j++) { if(j>6) { if(a[i][j]!=a[i][6]) mark1=0; if(a[i][j]!=a[i][j-1]+1) mark2=0; if(a[i][j]!=a[i][j-1]-1) mark4=0; } if(j>=3) { t1=a[i][j]-'0'; t2=t2*10+t1; } } int year=t2/10000; int month=t2%10000/100; int day=t2%100; if(year>=1980&&year<=2016) { if(month<=12&&month>=1&&day>=1&&day<=data[month]) mark3=1; if((year-1980)%4==0) if(month==2&&day==29) mark3=1; } if(mark1||mark2||mark3||mark4) count+=price1; else count+=price2; } printf("%I64d\n",count); } return 0; }