1 solutions

  • 0
    @ 2025-3-3 16:33:58

    C++ :

    #include<iostream>
    using namespace std;
    
    int main(){
    	
    	int l;
    	cin>>l;
    	int i,j,k;
    	int s;
    	s=0; 
    	
    	
    	for(i=1;i<=l/3;i++){
    		for(j=i;j<=l/2;j++){
    			k=l-i-j;
    			if((k==j && j!=i) || k>j){
    				if(i+j>k && i+k>j && j+k>i){
    						s++;
    				}
    			
    			}
    		}
    	} 
    	
    	cout<<s<<endl;
    }
    
    

    Python :

    L=int(input())
    count=0
    for i in range(1,L-1):
        for j in range(i,L-i):
            k=L-i-j
            if (k>=j and i+j>k and i+k>j and j+k>i):
                if (i==j and i==k):
                    continue
                else:
                    count=count+1
    print(count)
    
    • 1

    Information

    ID
    10808
    Time
    1000ms
    Memory
    16MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By