第四届蓝桥杯C++A组——高斯日记

来源:互联网 发布:詹姆斯各年总决赛数据 编辑:程序博客网 时间:2024/05/18 02:42

题目标题: 高斯日记

大数学家高斯有个好习惯:无论如何都要记日记。他的日记有个与众不同的地方,他从不注明年月日,而是用一个整数代替,比如:4210后来人们知道,那个整数就是日期,它表示那一天是高斯出生后的第几天。这或许也是个好习惯,它时时刻刻提醒着主人:日子又过去一天,还有多少时光可以用于浪费呢?高斯出生于:1777年4月30日。在高斯发现的一个重要定理的日记上标注着:5343,因此可算出那天是:1791年12月15日。高斯获得博士学位的那天日记上标着:8113   请你算出高斯获得博士学位的年月日。

提交答案的格式是:yyyy-mm-dd, 例如:1980-03-21

请严格按照格式,通过浏览器提交答案。
注意:只提交这个日期,不要写其它附加内容,比如:说明性的文字。

开始无耻地凑博客文章数了

#include <iostream>#include <cstring>#include <string>#include <vector>#include <queue>#include <cstdio>#include <set>#include <cmath>#include <algorithm>#include <queue>#define INF 0x3f3f3f3f#define MAXN 100005#define Mod 10001using namespace std;int month1[]={0,31,28,31,30,31,30,31,31,30,31,30,31};int month2[]={0,31,29,31,30,31,30,31,31,30,31,30,31};int main(){    int year=1777,mon=4,day=30;    int cnt=1;    while(cnt<8113)    {        cnt++;        day++;        if((year%4==0&&year%100!=0)||(year%400==0))        {            if(day>month2[mon])            {                day=1;                mon++;            }            if(mon>12)            {                mon=1;                year++;            }        }        else        {            if(day>month1[mon])            {                day=1;                mon++;            }            if(mon>12)            {                mon=1;                year++;            }        }    }    cout<<year<<"-"<<mon<<"-"<<day;    return 0;}
0 0
原创粉丝点击