求助大佬 一个AC

P5737 【深基7.例3】闰年展示

青鸟AK @ 2020-03-24 12:05:14

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int h,t,cnt=0;
    cin>>h>>t;
    for(register int i=h;i<=t;i++)
    {
        if((i%400==0||i%4==0)&&(i%100))
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;
    for(register int i=h;i<=t;i++)
    {
        if((i%400==0||i%4==0)&&(i%100))
        {
            cout<<i<<' ';
        }
    }
    return 0;
}

by 江户川·萝卜 @ 2020-03-24 12:06:56

if里面年份只要是100的倍数就false了


by FCBM71 @ 2020-03-24 12:07:33

(i%400==0||i%4==0)&&(i%100)

这是什么神仙逻辑


by 江户川·萝卜 @ 2020-03-24 12:09:10

@HyyypRtf06 素数??


by zmxqs @ 2020-03-24 12:10:40

头像好评++


by zmxqs @ 2020-03-24 12:11:16

鼓掌!


by Water_Cows @ 2020-03-24 12:12:28


by 青鸟AK @ 2020-03-24 12:14:24

改对了


by liqingyang @ 2020-03-24 12:15:39

鼓掌!


by Yukinoshita_Yukino @ 2020-03-24 12:19:05

鼓掌


by UnyieldingTrilobite @ 2020-03-24 12:21:04

鼓掌


| 下一页