fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int a, b, c;
  6. cin >> a >> b >> c;
  7.  
  8.  
  9. if (b - a == c - b) {
  10. cout << c + (b - a) << endl;
  11. }
  12.  
  13. else if (b % a == 0 && c % b == 0 && (b / a == c / b)) {
  14. cout << c * (b / a) << endl;
  15. }
  16.  
  17. else {
  18. cout << -1 << endl;
  19. }
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0.01s 5288KB
stdin
1 5 9
3 12 48
1 3 4
stdout
13