/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Wrong Answer 257ms 568.0 KiB
#3 Wrong Answer 256ms 600.0 KiB

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){
            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:56:26
Judged At
2024-11-11 03:23:21
Judged By
Score
10
Total Time
257ms
Peak Memory
600.0 KiB