9 条题解
-
0
懒人代码
#include<bits/stdc++.h> using namespace std; const int INF=0x3f3f3f3f; int const N=1e5+10; int x,y; int main(){ cin>>x>>y; if(y==2){ if(x%4==0&&x%100!=0||x%400==0){ cout<<29; return 0; }else{ cout<<28; return 0; } } if(y==1||y==3||y==5||y==7||y==8||y==10||y==12)cout<<31; else{ cout<<30; } return 0; }
-
0
#include using namespace std; int main(){ int x,y,b=0; cin>>x>>y; if(x%40) b=1; if(x%1000) b=0; if(x%4000) b=1; if(y2){ if(b0){ cout<<"28"; }else{ cout<<"29"; } } if(y1||y3||y5||y7||y8||y10||y12){ cout<<"31"; }else{ if(y!=2){ cout<<"30"; }
} return 0;
} //这是绝对AC的代码,并且怎样测试都不会出错(2000年 3月出现的是31)
-
0
可能有点长,不是最优解
#include<bits/stdc++.h> using namespace std; int main(){ int x,y,b; cin>>x>>y; if(y<=0 || y>12) cout<<"no answer"; if(x%400==0) b=1; else if(x%100==0) b=0; else if(x%4==0) b=1; else b=0; if(b==1) { if(y==1 || y==3 || y==5 || y==7 || y==8 || y==10 ||y==12) cout<<"31"; else if(y==4 || y==6 || y==9 || y==11 ) cout<<"30"; else if(y==2) cout<<"29"; } if(b==0) { if(y==1 || y==3 || y==5 || y==7 || y==8 || y==10 ||y==12) cout<<"31"; else if(y==4 || y==6 || y==9 || y==11 ) cout<<"30"; else if(y==2) cout<<"28"; } return 0; }
-
0
#include
using namespace std;
int main()
{
int a,b=0,c; cin>>a>>c; if(a%4==0) b=1;//普通闰年 if(a%100==0) b=0;//普通闰年 if(a%400==0) b=1;//世纪闰年,此为重点!!测点一就是测这个 if(c==2){ if(b==0){ cout<<"28"; }else{ cout<<"29"; } } if(c==1&&c==3&&c==5&&c==7&&c==8&&c==10&&c==12){ cout<<"31"; }else{ if(c!=2){ cout<<"30"; } }
}
-
-1
#include<stdio.h> #include using namespace std; int main() { int x,y; cin>>x>>y; if((x%40&&x%100!=0)||(x%4000)) { if(y2) { cout<<29<<endl; }else if(y1||y3||y5||y7||y8||y12) { cout<<31<<endl; }else { cout<<30<<endl; } }else { if(y2) { cout<<28<<endl; }else if(y1||y3||y5||y7||y8||y12) { cout<<31<<endl; }else { cout<<30<<endl; } } }
- 1
信息
- ID
- 863
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 6
- 标签
- 递交数
- 745
- 已通过
- 225
- 上传者