9 条题解

  • 1

    可能有点长,不是最优解

    #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;
    }
    
    • 1
      @ 2022-3-31 20:49:11

      #include<iostream>

      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";
      
      	}
      
      }
      

      }

      • 0
        @ 2024-5-29 20:26:49

        #include<iostream> #include<cstdio> #include<iomanip> #include<cmath> using namespace std; int main() { int a,b,c; cin>>a>>b>>c; if(a+b>c){if (c+b>a){if(a+c>b){cout<<"yes"; }else{cout<<"no";} }else{cout<<"no";} }else{cout<<"no";} return 0; }

        • 0
          @ 2024-5-4 20:20:17

          懒人代码

          #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
            @ 2024-4-16 20:43:07

            #include <iostream> 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
              @ 2022-10-15 10:58:24

              #include<iostream>
              using namespace std;
              int main(){
              int y=0;
              int m=0;
              int days[]={ 31,28,31,30,31,30,31,31,30,31,30,31};
              while(scanf("%d %d", &y,&m)!=EOF) {
              int day=days[m-1];
              if((y%40&&y%100!=0)||(y%4000)){
              if(m==2){
              day++;
              }
              }
              printf("%d\n",day);
              }
              return 0;
              }

              • -1
                @ 2022-7-3 9:05:00

                #include<stdio.h> #include<iostream> 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
                  @ 2022-2-9 11:44:57

                  #include <stdio.h> #include <iostream> using namespace std; int main() { int y,m; cin >> y >> m; int sum = 0; if(m1||m3||m5||m7||m8||m10||m==12) { sum = 31; } else if(m != 2) { sum = 30; } else { sum = 28; if (y%400 == 0||y%100 != 0 && y%4 == 0) sum += 1; } cout << sum; }

                  • -2
                    @ 2022-2-9 11:39:43

                    #include<iostream> #include<stdio.h> using namespace std; int main() { int y,m; cin>>y>>m; int sum=0; if(m1||m3||m5||m7||m8||m10||m=12) { sum=31; } else if(m !=2) { sum=30; } else { sum=28; if(y%4000 ||(y%100 !=0 && y%40)) sum+=1; } cout<<sum<<endl; }

                    • 1

                    信息

                    ID
                    863
                    时间
                    1000ms
                    内存
                    256MiB
                    难度
                    6
                    标签
                    递交数
                    716
                    已通过
                    217
                    上传者