BestCoder #69 Baby Ming and phone number(HDOJ5611)
来源:互联网 发布:2007年网络流行歌曲 编辑:程序博客网 时间:2024/06/05 05:23
Baby Ming and phone number
Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Problem Description
Baby Ming collected lots of cell phone numbers, and he wants to sell them for money.
Baby Ming collected lots of cell phone numbers, and he wants to sell them for money.
He thinks normal number can be sold for bb yuan, while number with following features can be sold for aa 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 11. (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 TT, indicating number of test case.
In the second line there is a positive integer nn, which means how many numbers Baby Ming has.(no two same phone number)
In the third line there are 22 positive integers a, ba,b, which means two kinds of phone number can sell aa yuan and bb yuan.
In the next nn lines there are nn cell phone numbers.(|phone number|==11, the first number can’t be 0)
1 <=T <= 30, b < 1000, 0 < a, n <= 100,000 ,1≤T≤30,b<1000,0<a,n≤100,000
Output
How much Baby Nero can earn.
水题,简单模拟,注意细节
#include<cstdio>#include<iostream>#include<string>#include<cstring>#include<string.h>#include<algorithm>#include<cmath>#include<cstdlib>using namespace std;char a[12];int brun[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };int run[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };int f(char a[]){ int flag = 1; for (int i = 6; i < 10; i++) { if (a[i] != a[i + 1] + 1) { flag = 0; } } if (flag) { if (a[10] >= '0')return 1; } flag = 1; for (int i = 6; i < 10; i++) { if (a[i] != a[i + 1] - 1) flag = 0; } if (flag) { if (a[10] <= '9')return 1; } flag = 1; for (int i = 6; i < 10; i++) { if (a[i] != a[i + 1]) flag = 0; } if (flag)return 1; int year = (a[3] - '0') * 1000 + (a[4] - '0') * 100 + (a[5] - '0') * 10 + (a[6] - '0'); if (year >= 1980 && year <= 2016) { int month = (a[7] - '0') * 10 + (a[8] - '0'); int day = (a[9] - '0') * 10 + (a[10] - '0'); if (month <= 0 || month > 12)return 0; if ((year % 400 == 0) || (year % 4 == 0 && year % 100 != 0)) { if (day <= run[month - 1])return 1; else return 0; } else { if (day <= brun[month - 1])return 1; else return 0; } } return 0;}int main(){ int T; cin >> T; while (T--) { int n; scanf("%d", &n); int x, y; scanf("%d %d", &x, &y); long long cot = 0; for (int i = 0; i < n; i++) { scanf("%s", a); if (f(a))cot += x; else cot += y; } printf("%I64d\n", cot); } system("pause"); return 0;}
0 0
- BestCoder #69 Baby Ming and phone number(HDOJ5611)
- BestCoder Round #69 (div.2) B HDOJ5611 Baby Ming and phone number(stl)
- BestCoder Round #69 (div.2)-Baby Ming and phone number(模拟)
- hdu 5611 /BC 69B Baby Ming and phone number
- Baby Ming and phone number(BC)
- HDU 5611: Baby Ming and phone number
- hdu5611 Baby Ming and phone number
- 5611 Baby Ming and phone number
- HDOJ 5611 Baby Ming and phone number
- HDU5611 Baby Ming and phone number 水题
- 【Best Coder】Baby Ming and phone number(水)
- hdoj 5611 Baby Ming and phone number 【模拟】
- HDOJ 5611 Baby Ming and phone number(模拟)
- HDOJ 5611 Baby Ming and phone number (模拟)
- hdoj Baby Ming and phone number 5611 (简单判断)
- HDU 5611 Baby Ming and phone number(模拟)
- HDOJ 5611-Baby Ming and phone number【模拟】
- HDU-5611 Baby Ming and phone number(模拟)
- google输入法 日文 [CapsLock]キー ひらがな⇔直接入力の設定
- DOM
- #android#android studio 使用cardview
- 怎样在win7中 安装Tomcat7.0
- luajit stack traceback() 显示不全
- BestCoder #69 Baby Ming and phone number(HDOJ5611)
- SQLAlchemy 简单笔记
- 文章标题
- HDU1495 广搜 喝水问题
- R语言中的svm实例
- 状态机
- I/O error 32/103
- C#成神之路 <21> 窗体操作相关
- 虚拟IP原理