2 条题解

  • 0
    @ 2025-2-15 20:27:50

    Code

    #include <bits/stdc++.h>
    
    using namespace std;
    
    int n,ans=0,b=0;
    string c="   ";
    
    int f(int a){
    	if(a>=85){
    		return 4;
    	}
    	if(a>=45){
    		return 3;
    	}
    	if(a>=25){
    		return 2;
    	}
    	if(a>=1){
    		return 1;
    	}
    	return 0;
    }
    
    bool cmp(char a,char b){
    	return a>b;
    }
    
    int main(){
    	for(int x=0;x<3;x++){
    		cin>>n;
    		c[x]=char(f(n)+'0');
    	}
    	sort(c.begin(),c.end(),cmp);
    	if(c=="321" || c=="432" || c=="442" || c=="443" || c=="444"){
    		cout<<"Yes";
    	}else{
    		cout<<"No";
    	}
    	return 0;
    }
    
    • -2
      @ 2025-1-20 16:39:43

      标题

      思路

      解题方法

      一个一个的判断每一种情况即可。

      复杂度

      时间复杂度:

      添加时间复杂度, O(1)O(1)

      Code

      #include<bits/stdc++.h>

      using namespace std;

      long long a,b,c,x,y,z;

      long long f(long long a){

      long long s;
      
      if(a>=85&&a<=100) s=1;
      
      else if(a>=45&&a<=84) s=2;
      
      else if(a>=25&&a<=44) s=3;
      
      else if(a>=1&&a<=24) s=4;
      
      else s=0;
      
      return s;
      

      }

      int main(){

      cin>>a>>b>>c;
      
      long long s[4]={0,f(a),f(b),f(c)};
      
      if(s[1]==0||s[2]==0||s[3]==0){
      
      	cout<<"No";
      
      	return 0;
      
      }
      
      sort(s+1,s+4);
      
      x=s[1],y=s[2],z=s[3];
      
      if(x==1){
      
      	if(y==1){
      
      		if(z==4) cout<<"No";
              
      		else cout<<"Yes";
      	}
      	else if(y==2){
      		if(z==3) cout<<"Yes";
      		else cout<<"No";
      	}
      	else cout<<"No";
      }
      else if(x==2&&y==3&&z==4) cout<<"Yes";
      else cout<<"No";
      return 0;
      

      }

      • 1

      信息

      ID
      101
      时间
      3000ms
      内存
      512MiB
      难度
      1
      标签
      递交数
      321
      已通过
      202
      上传者