HDU 5611 Baby Ming and phone number(字符串模拟)
来源:互联网 发布:聊天软件默默 编辑:程序博客网 时间:2024/06/05 01:51
本题为简答的字符串模拟题目
AC代码如下:
#include<cstdio>#include<cstring>#include<iostream>using namespace std;char s[15]; int runnian(int n){ if(n%400==0||(n%4==0&&n%100!=0)) return 1; return 0;}int main(){ int t,n,a,b,i; long long sum; scanf("%d",&t); while(t--) { scanf("%d",&n); scanf("%d%d",&a,&b); sum=0; while(n--) { scanf("%s",s); int days[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; if(s[6]==s[7]&&s[7]==s[8]&&s[8]==s[9]&&s[9]==s[10]) sum+=a; else if(s[6]-1==s[7]&&s[7]-1==s[8]&&s[8]-1==s[9]&&s[9]-1==s[10]) sum+=a; else if(s[6]+1==s[7]&&s[7]+1==s[8]&&s[8]+1==s[9]&&s[9]+1==s[10]) sum+=a; else { int year=0,month=0,day=0; year=(s[3]-'0')*1000+(s[4]-'0')*100+(s[5]-'0')*10+(s[6]-'0'); month=(s[7]-'0')*10+(s[8]-'0'); day=(s[9]-'0')*10+(s[10]-'0'); int flag=0; if(year<1980||year>2016) flag=1; else { int cnt=runnian(year); if(cnt) days[2]++; if(month<1||month>12) flag=1; else { if(day>days[month]||day<1) flag=1; } } if(flag==0) 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 (简单判断)
- jvm频繁GC问题查找记录
- Android Studio 模拟器无法启动问题(x86 emulation currently requires hardware acceleration。。。)
- HDOJ 最短路
- ActiveMQ持久化方式
- React插件-双向绑定辅助工具
- HDU 5611 Baby Ming and phone number(字符串模拟)
- 二叉树遍历,递归和非递归方法
- OnCollisionEnter OnTriggerEnter 区别
- Benchmark库的建立03:空指针异常Bug
- PHP json_encode()
- android自定义adapter之简单写法
- Powershell工作流中的function和script
- iOS 微信支付
- android三种实现定时器的方式