zps1122 @ 2022-03-13 22:23:28
#include<bits/stdc++.h>
using namespace std;
int l,r;
int ans=0;
int a[2000];
int main(){
cin>>l>>r;
for(int i=l;i<=r;i++){
if(i%100==0){
if(i%400==0){
ans++;
a[ans]=i;
i++;
}
}
if(i%4==0){
ans++;
a[ans]=i;
}
}
cout<<ans<<endl;
for(int i=1;i<=ans;i++){
cout<<a[i]<<" ";
}
return 0;
}
by zps1122 @ 2022-03-13 22:34:15
#include<bits/stdc++.h>
using namespace std;
int l,r;
int ans=0;
int a[2000];
int main(){
cin>>l>>r;
for(int i=l;i<=r;i++){
if(i%400==0){
ans++;
a[ans]=i;
continue;
}
if(i%4==0&&i%100!=0){
ans++;
a[ans]=i;
}
}
cout<<ans<<endl;
for(int i=1;i<=ans;i++){
cout<<a[i]<<" ";
}
return 0;
}
by limeng911 @ 2022-04-14 22:19:34
#include<bits/stdc++.h>
using namespace std;
int main(){
int p,q;
cin>>p>>q;
int a=p,c=0;
for(;a<=q;){
if((a%4==0 && a%100!=0) || a%400==0){
c=c+1;
}
a=a+1;
}
cout<<c<<endl;
a=p ;
for(;a<=q;){
if((a%4==0 && a%100!=0) || a%400==0){
cout<<a<<" ";
c=c+1;
}
a=a+1;
}
cout<<endl;
return 0;
}