题解

129 条题解

  • 0
    @ 2014-10-03 16:45:15

    #include <cstdio>

    unsigned int year, month, day;

    unsigned int cnt(0);

    unsigned int test_day(const unsigned int &year, const unsigned int &month)
    {
    if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
    return 31;
    if (month == 2)
    return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) ? 29 : 28;
    return 30;
    }

    int main()
    {
    using namespace std;

    scanf("%u%u%u", &year, &month, &day);

    while (cnt != 10000)
    {
    if (day == test_day(year, month))
    if (month == 12)
    {
    ++year;
    month = day = 1;
    }
    else
    {
    ++month;
    day = 1;
    }
    else
    ++day;

    ++cnt;

    }

    printf("%u-%u-%u", year, month, day);

    return 0;
    }

  • 0
    @ 2014-09-20 12:45:07

    #include <iostream>

    using namespace std;

    int year,month,day;

    void init ()
    {
    cin>>year>>month>>day;
    }

    int data;
    int t[3][13];

    void make ()
    {
    t[1][1]=31;
    t[1][2]=28;
    t[1][3]=31;
    t[1][4]=30;
    t[1][5]=31;
    t[1][6]=30;
    t[1][7]=31;
    t[1][8]=31;
    t[1][9]=30;
    t[1][10]=31;
    t[1][11]=30;
    t[1][12]=31;
    t[2][1]=31;
    t[2][2]=29;
    t[2][3]=31;
    t[2][4]=30;
    t[2][5]=31;
    t[2][6]=30;
    t[2][7]=31;
    t[2][8]=31;
    t[2][9]=30;
    t[2][10]=31;
    t[2][11]=30;
    t[2][12]=31;
    }

    int pd ()
    {
    if (year%4==0)
    return 2;
    else
    return 1;
    }

    void work ()
    {
    int i,k;
    make ();
    k=pd ();
    while (1)
    {
    day++;
    if (t[k][month]==day-1)
    {
    day=1;
    month++;
    }
    if (month==13)
    {
    year++;
    month=1;
    k=pd ();
    }
    data++;
    if (data==10000)
    break;
    }
    }

    void output ()
    {
    cout<<year<<'-'<<month<<'-'<<day<<endl;
    }

    int main ()
    {
    init ();
    work ();
    output ();
    // system("pause");
    return 0;
    }

  • 0
    @ 2014-08-22 14:19:40

    #include<iostream>
    #include<fstream>
    #include<cmath>
    #include<cstring>
    #include<cstdio>
    #include<cstdlib>
    using namespace std;
    int ping[12]={31,28,31,30,31,30,31,31,30,31,30,31};
    int run[12]={31,29,31,30,31,30,31,31,30,31,30,31};
    int year,month,day;
    int main()
    {

    scanf("%d %d %d\n",&year,&month,&day);
    for (int i=0; i<10000; i++)
    {
    day++;
    if (year%4==0)
    {
    if (day>run[month-1])
    {

    day=1;month+=1;
    }
    else;
    if (month>12)
    {
    year++;month=1;
    }
    else;
    }
    else
    {
    if (day>ping[month-1])
    {
    day=1;month+=1;
    }
    else;
    if (month>12)
    {
    year++;month=1;
    }else;
    }
    }
    printf("%d-%d-%d\n",year,month,day);
    return 0;
    }
    博皓接招!

  • 0
    @ 2014-08-22 14:12:08

    定义两个数组
    一个记录平年天数 另一个记录闰年天数
    通过对年数是否为闰年的判断 然后输出日期

    做模拟时要注意细节 对于日期要有一定的把控
    定义年份 过了一个月将日初始为1 以此类推
    将简单思路送给我的好朋友张博皓

  • 0
    @ 2014-05-11 01:15:19

    #include <cstdio>
    int main(void){
    int dm1[12]={31,28,31,30,31,30,31,31,30,31,30,31},
    dm2[12]={31,29,31,30,31,30,31,31,30,31,30,31},
    y,m,d;
    scanf("%d %d %d\n",&y,&m,&d);
    for (int i=0; i<10000; i++) {
    d++;
    if (y%4==0) {
    if (d>dm2[m-1]) {
    d=1;m+=1;
    }else;
    if (m>12) {
    y++;m=1;
    }else;
    }
    else {
    if (d>dm1[m-1]) {
    d=1;m+=1;
    }else;
    if (m>12) {
    y++;m=1;
    }else;
    }
    }
    printf("%d-%d-%d\n",y,m,d);
    }

  • 0
    @ 2013-11-25 21:32:38

    #include<cstdio>
    int year,month,day;
    int Leap(int y){int leap;leap=(y%4==0&&y%100!=0||y%400==0);return leap;}
    main(){
    int m[13]={0,31,0,31,30,31,30,31,31,30,31,30,31},i;
    scanf("%d%d%d",&year,&month,&day);
    for(i=1;i<=10000;i++)
    {
    if(Leap(year)) m[2]=29;
    else m[2]=28;
    day++;
    if(day==m[month]+1)
    {
    month++;
    day=1;
    }
    if(month==13)
    {
    year++;
    month=1;
    }
    }printf("%d-%d-%d\n",year,month,day);
    }

  • 0
    @ 2013-07-16 10:16:35

    样例输出是2006-09-01,而测试数据中把样例中的月日前的‘0’省掉了

  • 0
    @ 2012-11-02 22:21:41

    楼下的代码好长啊...

    的确很水啊

    program P1211;

    var

    y,m,d,i,j:integer;

    begin

    read(y,m,d);

    for i:=1 to 10000 do

    begin

    d:=d+1;

    case m of

    1,3,5,7,8,10,12:j:=31;

    4,6,9,11:j:=30;

    2:if ((y mod 4=0)and(y mod 1000))or(y mod 400=0) then j:=29

    else j:=28;

    end;

    if d>j then begin  m:=m+1; d:=d-j; end;

    if m>12 then begin y:=y+1; m:=m-12;

    end;

    end;

    write(y,'-',m,'-',d);

    end.

    保证0ms通过

  • 0
    @ 2012-08-21 15:37:13

    AC70纪念!!!

    program p1121;

    const cmonth:array[1..12] of word=(31,28,31,30,31,30,31,31,30,31,30,31);

    smonth:array[1..12] of word=(31,29,31,30,31,30,31,31,30,31,30,31);

    syear:array[1900..2100] of boolean=(false,false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,

    false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,

    false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,

    false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,

    false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,

    false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,true,false,false,false,false);

    var year,month,day,nowm,nowy,nowd,i:longint;

    begin

    readln(year,month,day);

    nowy:=year;

    nowm:=month;

    nowd:=day;

    i:=0;

    while ismonth[nowm]) then

    begin

    nowm:=nowm+1;

    nowd:=1;

    if (nowm>12) then

    begin

    nowy:=nowy+1;

    nowm:=1;

    end;

    end;

    end

    else begin

    nowd:=nowd+1;

    if (nowd>cmonth[nowm]) then

    begin

    nowm:=nowm+1;

    nowd:=1;

    if (nowm>12) then

    begin

    nowy:=nowy+1;

    nowm:=1;

    end;

    end;

    end;

    i:=i+1;

    end;

    writeln(nowy,'-',nowm,'-',nowd);

    end.

  • 0
    @ 2009-11-06 22:34:32

    这题居然还是我一星半纪念题!!啊~!感慨一句,真的太农夫山泉了,今天喝了好多农夫山泉啊~!

    Flag   Accepted

    题号   P1211

    类型(?)   其它

    通过   2781人

    提交   5822次

    通过率   48%

    难度   1

    #include

    short month1[13]={29,31,28,31,30,31,30,31,31,30,31,30,31},year,month,day;

    short runnian(long x)

    {

    if ((x%100==0)&&(x%400==0)) return 1;

    else if ((x%100!=0)&&(x%4==0)) return 1;

    else return 0;

    }

    int main()

    {

    short i,t,flag=0;

    scanf("%ld%ld%ld",&year,&month,&day);

    if ((month12)

    {

    year++;

    month=1;

    t=1;

    if (runnian(year)==1) flag=1;

    else flag=0;

    }

    }

    printf("%ld-%ld-%ld\n",year,month,day);

    return 0;

    }

  • 0
    @ 2009-11-06 20:18:25

    var year,month,day:integer;

    d:integer;

    begin

    readln(year,month,day);

    d:=0;

    repeat

    d:=d+1;

    day:=day+1;

    if (day>28)and(month=2)and((year mod 40)and(year mod 4000)) then

    begin month:=month+1;day:=1;end;

    if (day>29)and(month=2)and(year mod 4=0) then

    begin month:=month+1;day:=1;end;

    if day>30 then

    case month of

    4,6,9,11:begin month:=month+1;day:=1;end;

    end;

    if day>31 then

    case month of

    1,3,5,7,8,10:begin month:=month+1;day:=1;end;

    12:begin month:=1;day:=1;year:=year+1;end;

    end;

    until d=10000;

    writeln(year,'-',month,'-',day);

    end.

  • 0
    @ 2009-11-03 21:29:27

    本题含水量仅次于A+B problem!

  • 0
    @ 2009-11-03 21:17:22

    .................

    未写完 的程序,先保存...

    - -

    {uses sysutils;

    var y,m,d:integer;

    day:integer;

    s:integer;

    function calcd(day:integer):integer;

    begin

    calcd:=0;

    if day

    function calcm(t,mouth:integer):integer;

    begin

    if t=0 then

    begin

    calcm:=0;

    calcm(1,mouth)

    end

    else

    case m of

    1:exit(calcm+31);

    2:begin

    if isleapyear(y) then inc(calcm,29)

    else inc(calcm,28);

    calcm(1,m-1);

    end;

    3,5,7,8,10,12:begin inc(calcm,31); calcm(1,m-1) end;

    4,6,9,11:begin inc(calcm,30); calcm(1,m-1) end;

    end;

    end;

    begin

    readln(y,m,d);

    day:=366-calcm(0,m)-d-1;

    if not(isleapyear(y)) then dec(day);

    s:=10000-day;

    while s>=365 do

    begin

    inc(y);

    if isleapyear(y) then dec(s,366)

    else dec(s,365);

    end;

    if s=0 then

    begin

    writeln(y,'-1-1');

    halt;

    end;

    if s

  • 0
    @ 2009-10-30 20:52:21

    啊呀

    忘记考虑

    日子刚好最后一天的了!!!

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案错误... 

    ├ 标准行输出 ...80-2-2...

    ├ 错误行输出 ...80-3-0...

    ├ 测试数据 05:答案错误... 

    ├ 标准行输出 ...00-2-2...

    ├ 错误行输出 ...00-3-0...

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    看看啊看看啊看看啊看看啊看看啊看看啊看看啊看看啊看看啊看看啊看看啊看看啊看看啊

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    程序保密~~~~~~~~~~~~!!!!!!!!!!!

    管理员别删!~

    Flag    Accepted

    题号   P1211

    类型(?)   其它

    通过   2765人

    提交   5782次

    通过率   48%

    难度   1

  • 0
    @ 2009-10-30 10:02:16

    啊! 有水题!**同志们刷呀!!! **

  • 0
    @ 2009-10-19 16:59:51

    直接for i:=1 to 10000模拟一遍即可!

  • 0
    @ 2009-09-25 12:55:16

    一次性编译通过,一次性运行通过,一次性评测通过~

    一次性发现——水~

  • 0
    @ 2009-09-17 21:07:04

    水题= =、

    本座鉴定

    无比水

  • 0
    @ 2009-09-17 12:39:07

    const

    p:array[1..12] of integer=(31,28,31,30,31,30,31,31,30,31,30,31);

    var

    i,y,m,d:longint;

    begin

    readln(y,m,d);

    i:=0;

    while (i12 then begin m:=1;y:=y+1; end;

    end;

    writeln(y,'-',m,'-',d);

    end.

    AC

  • 0
    @ 2009-09-14 19:34:24

    何子睿是个傻B!!!

    乱打的!!!!!!!

信息

ID
1211
难度
3
分类
模拟 点击显示
标签
(无)
递交数
2740
已通过
1333
通过率
49%
被复制
16
上传者