daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest Jan 23rd, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.    
  7.     int a, b, c, d, s1 = 0, s2 = 0;
  8.    
  9.     cin>>a>>b>>c>>d;
  10.    
  11.     for(int n = 1;n < 10;n++)
  12.     {
  13.         s1 = b+(2*a+(n-1)*a)*n/2;
  14.         s2 = d+(2*c+(n-1)*c)*n/2;
  15.        
  16.         if(s1 == s2){
  17.             cout<<s1;
  18.             return 0;
  19.         }
  20.     }
  21.     cout<<-1;
  22.    
  23. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top