wrk20111205 @ 2023-08-20 21:54:22
#include<iostream>
using namespace std;
int a,b,i,s=0,c[10000001];
int rn(int i)
{
if(i%4==0)
{
return 0;
}
else
{
return 1;
}
}
int main()
{
cin>>a>>b;
for(i=a;i<=b;i++)
{
if(rn(i)==0)
{
s++;
c[s]=i;
}
}
cout<<s<<endl;
for(i=1;i<=s;i++)
{
cout<<c[i]<<" ";
}
return 0;
}
by _buzhidao_ @ 2023-08-20 21:56:15
@wrk20111205
#include<bits/stdc++.h>
using namespace std;
short a,b,c[400],d;
int main(){
cin>>a>>b;
for(short i=a;i<=b;i++){
if(i%4==0&&(i%100!=0||i%400==0)){
c[d]=i;d++;
}
}
cout<<d<<endl;
for(short i=0;i<d;i++) cout<<c[i]<<' ';
return 0;
}
by _buzhidao_ @ 2023-08-20 21:56:59
@wrk20111205 四年一闰,百年不闰,四百年再闰。
by FurippuWRY @ 2023-08-20 22:00:37
@wrk20111205 闰年判断不对
#include<bits/stdc++.h>
using namespace std;
bool r(long long i){
if(i%4==0 && i%100!=0 || i%400==0 && i%3200!=0) return 1;
else return 0;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
long long x,y,a=0;
cin>>x>>y;
for(int i=x;i<=y;++i){
if(r(i)) a++;
}
cout<<a<<endl;
for(int j=x;j<=y;++j){
if(r(j)) cout<<j<<" ";
}
return 0;
}