/ SeriousOJ /

Record Detail

Compile Error

foo.cc: In function 'int main()':
foo.cc:30:27: error: lvalue required as left operand of assignment
   30 |         else if(a==b||b==c||a=c){
      |                 ~~~~~~~~~~^~~

Code

// Online C++ compiler to run C++ program online
#include <iostream>
using namespace std;

int gcd(int a, int b) 
{ 
    
    int result = min(a, b); 
    while (result > 0) { 
        if (a % result == 0 && b % result == 0) { 
            break; 
        } 
        result--; 
    } 
  
   
    return result; 
}

int main() {
    int t;
    cin>>t;
    while(t--){
        int a,b,c,diff1=0,diff2=0,final=0;
        cin>>a>>b>>c;
        
        if(a==b&&a==c){
            final=0;
        }
        else if(a==b||b==c||a=c){
            final=1;
        }
       
       else {
            
        if(a>b){
            diff1=a-b;
        }
        if(b>a){
            diff1=b-a;
        }
        
        if(b>c){
            diff2=b-c;
        }
        
        if(c>b){
            diff2=c-b;
        }
        
        
        
        int ans=gcd(diff1,diff2);
        cout<<ans<<endl;
        
        
        if(ans==1){
            final=diff1+diff2;
        }
        else
        {
            final=(diff1/ans)+(diff2/ans);
        }
        
           
           
           
           
           
           
       }
       
       cout<<final<<endl;
        
        
        
        
        
        
        
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1061 Bring equality
Contest
Brain Booster #4
Language
C++17 (G++ 13.2.0)
Submit At
2024-07-14 16:57:52
Judged At
2024-11-11 03:23:20
Judged By
Score
0
Total Time
0ms
Peak Memory
0 Bytes