• Codeforces Round #183 (Div. 2) B. Calendar


    题目:http://codeforces.com/contest/304/problem/B
    #include <iostream> #include <stdio.h> #include <string> #include <string.h> #include <algorithm> #include <math.h> #include <fstream> #include <vector> #include <map> #include <queue> #include <stack> #include <math.h> #include <stdlib.h> #include <set> #include <sstream> using namespace std ; int month[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31}; int leapyear(int y){ return (!(y%4) && y%100) || (!(y%400)); } int main(){ int ys,ms,ds,ye,me,de; while(~scanf("%d:%d:%d",&ys,&ms,&ds)){ scanf("%d:%d:%d",&ye,&me,&de); if(ye<ys || (ye == ys && ms>me) || (ye == ys && ms == me && ds > de)){ swap(ys, ye); swap(ms, me); swap(ds, de); } int ans = 0; if(ys == ye && ms == me){ printf("%d\n",de-ds); continue; } if(ys == ye){ if(leapyear(ys) && ms == 2) ans += month[2]+1 - ds; else ans += month[ms] - ds; for(int i = ms+1;i < me;i++){ if(leapyear(ys) && i == 2) ans += month[i]+1; else ans += month[i]; } ans += de; printf("%d\n",ans); continue; } if(leapyear(ys) && ms == 2) ans += month[2]+1 - ds; else ans += month[ms] - ds; //printf("%d\n",ans); for(int i = ms+1;i <= 12;i++){ if(leapyear(ys) && i == 2) ans += month[i]+1; else ans += month[i]; } //printf("%d\n",ans); for(int i = ys+1;i < ye;i++){ if(leapyear(i)) ans += 366; else ans += 365; } //printf("%d\n",ans); for(int i = 1;i < me;i++){ if(leapyear(ye) && i == 2) ans += month[i]+1; else ans += month[i]; } //printf("%d\n",ans); ans += de; printf("%d\n",ans); } return 0; }
  • 相关阅读:
    Mybatis result相关查询标签使用细则
    9.4 代码缓存 Java性能优化节选
    JarScan
    碎片 Java性能优化节选
    小方法的好处 Java性能优化p203
    HotSpot JIT基础
    JITWatch
    新手电吉他是三单还是单单双?
    JIT编译日志
    修改Oracle数据库的字符集(UTF8→ZHS16GBK)
  • 原文地址:https://www.cnblogs.com/Roly/p/3077129.html
Copyright © 2020-2023  润新知