HDU 5611 Baby Ming and phone number(模拟)
来源:互联网 发布:微信商城网站源码php 编辑:程序博客网 时间:2024/06/05 19:23
题目地址:点击打开链接
思路:注意闰年 的情况就行,还有就是最后输出的数要用long long 存
AC代码:
#include <iostream>#include <cstdio>#include <cstdlib>#include <algorithm>#include <queue>#include <stack>#include <map>#include <cstring>#include <climits>#include <cmath>#include <cctype>typedef long long ll;using namespace std;char cf[20];int lol[20];bool check(){ int i; for(i=6; i<10; i++) { if(lol[i] != lol[i+1]) { break; } } if(i == 10) return true; for(i=6; i<10; i++) { if(lol[i] + 1 != lol[i+1]) break; } if(i == 10) return true; for(i=6; i<10; i++) { if(lol[i] - 1 != lol[i+1]) break; } if(i == 10) return true; int year = lol[3] * 1000 + lol[4] * 100 + lol[5] * 10 + lol[6]; if(year < 1980 || year > 2016) return false; int month = lol[7] * 10 + lol[8]; if(month <1 || month > 12) return false; int day = lol[9] * 10 + lol[10]; if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) { if(day <1 || day > 31) return false; } else if(month == 2) { if((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)//这里把条件写成了year % 100 == 1,wrong了好多发,傻逼了 { if(day < 1 || day > 29) return false; } else if(day < 1 || day > 28) { return false; } } else if(day <1 || day > 30) { return false; } return true;}int main(){ int t,n,a,b; int i,j; scanf("%d",&t); while(t--) { scanf("%d",&n); scanf("%d%d",&a,&b); ll sum = 0; for(i=0; i<n; i++) { scanf("%s",cf); for(j=0; j<11; j++) { lol[j] = cf[j] - '0'; } if(check()) { sum += a; } else { sum += b; } } printf("%I64d\n",sum); } return 0;}
0 0
- HDU 5611 Baby Ming and phone number(模拟)
- HDU-5611 Baby Ming and phone number(模拟)
- HDU 5611 Baby Ming and phone number(字符串模拟)
- HDU 5611: Baby Ming and phone number
- HDOJ 5611 Baby Ming and phone number (模拟)
- hdoj 5611 Baby Ming and phone number(模拟)
- HDU 5611 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【模拟】
- hdu 5611 /BC 69B Baby Ming and phone number
- Hdu 5611 Baby Ming and phone number【日期计算等等】
- 5611 Baby Ming and phone number
- HDOJ 5611 Baby Ming and phone number
- Baby Ming and phone number(BC)
- hdoj--5611--Baby Ming and phone number(模拟水题)
- HDOJ--5611(Baby Ming and phone number)(闰年)
- hdoj Baby Ming and phone number 5611 (简单判断)
- 数学建模Word排版——细节决定成败
- 【黑马程序员】Foundation框架(二)
- 机器人操作系统ROS教程(三) ROS新手教程
- 0. 几个GPL授权问题
- 关于iOS遮罩的实现与透明度为0时自己的理解
- HDU 5611 Baby Ming and phone number(模拟)
- 83. Remove Duplicates from Sorted List && 82. Remove Duplicates from Sorted List II
- SAXReader通配符搜索XML节点
- 【quick-cocos2d-x】Lua 语言基础
- eclipse 关于The APR based Apache Tomcat Native library警告
- 以Attention Model为例谈谈两种研究创新模式
- 写正题之前,先给出几个关键字的中英文对照,重载(overload),覆盖(override),隐藏(hide)。在早期的C++书籍中,可能翻译的人不熟悉专业用语(也不能怪他们,他们不是搞计算机编程的,
- 输入一个数组,让所有奇数都在偶数前面
- UVA 11624 Fire!