按题意直接搞就可以了,就是写起来比较麻烦。。。
#include<iostream> #include<cstdio> #include<string> #include<string.h> #include<algorithm> #include<cstdlib> #include<ctime> #include<cmath> #include<iomanip> #include<map> #include<vector> #include<queue> #include<stack> //#include<bits/stdc++.h> using namespace std; typedef long long LL; const int INF = 0x3f3f3f3f; const int N = 1050; char str[15]; int main() { int t; cin>>t; int a,b; while(t--) { LL sum=0; int n; scanf("%d",&n); scanf("%d%d",&a,&b); getchar(); for(int i=0; i<n; ++i) { //cout<<sum<<endl; gets(str); bool flag=0; if(str[6]-'0'==str[7]-'0' && str[7]-'0'==str[8]-'0' && str[8]-'0'==str[9]-'0' && str[9]-'0'==str[10]-'0') { flag=1; } if(str[6]-'0'+1==str[7]-'0' && str[7]-'0'+1==str[8]-'0' && str[8]-'0'+1==str[9]-'0' && str[9]-'0'+1==str[10]-'0') { flag=1; } if(str[6]-'0'-1==str[7]-'0' && str[7]-'0'-1==str[8]-'0' && str[8]-'0'-1==str[9]-'0' && str[9]-'0'-1==str[10]-'0') { flag=1; } if(flag==1) { sum+=a; continue; } int nian=(str[3]-'0')*1000+(str[4]-'0')*100+(str[5]-'0')*10+(str[6]-'0')*1; int yue=(str[7]-'0')*10+(str[8]-'0')*1; int ri=(str[9]-'0')*10+(str[10]-'0')*1; // cout<<yue<<" "<<ri<<endl; if(nian<1980 || nian >2016) { sum+=b; continue; } if(yue<1 || yue >12) { sum+=b; continue; } if(ri<1 || ri >31) { sum+=b; continue; } if( (nian%4==0 && nian%100!=0) || (nian%400==0) ) { // cout<<"199"<<endl; if(yue==2) { if(ri<=29 && ri>=1) flag=1; } else if(yue==1 || yue==3 ||yue==5 ||yue==7 ||yue==8 ||yue==10 ||yue==12) { if(ri<=31 && ri>=1) flag=1; } else if(yue==4 || yue==6 ||yue==9 ||yue==11) { if(ri<=30 && ri>=1) flag=1; } } else { // cout<<"asd"<<endl; if(yue==2) { if(ri<=28 && ri>=1) flag=1; } else if(yue==1 || yue==3 ||yue==5 ||yue==7 ||yue==8 ||yue==10 ||yue==12) { if(ri<=31 && ri>=1) flag=1; } else if(yue==4 || yue==6 ||yue==9 ||yue==11) { if(ri<=30 && ri>=1) flag=1; } } if(flag==1) sum+=a; else sum+=b; } cout<<sum<<endl; } return 0; }
- 版权声明:本文基于《知识共享署名-相同方式共享 3.0 中国大陆许可协议》发布,转载请遵循本协议
- 文章链接:http://www.carlstedt.cn/archives/79 (转载时请注明本文出处及文章链接)
发表评论
快来吐槽一下吧!