Language: C++

#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

int div(int a, int b)
{
    return (a / b) + (a % b == 0 ? 0 : 1);
}

int main()
{
    int N;
    int A = 1;
    int T = 1;
    int a[1000];
    int t[1000];
    
    cin >> N;
    
    for (int i = 0; i < N; i++)
    {
        cin >> a[i] >> t[i];
    }
    
    for (int i = 0; i < N; i++)
    {
        int v = max(div(A, a[i]), div(T, t[i]));
        
        A = a[i] * v;
        T = t[i] * v;
    }
    
    cout << A + T << endl;
    
    return 0;
}


Compiler output:
a.cc:7:5: error: ambiguating new declaration of 'int div(int, int)'
    7 | int div(int a, int b)
      |     ^~~
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/ext/string_conversions.h:43,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/stdlib.h:992:14: note: old declaration 'div_t div(int, int)'
  992 | extern div_t div (int __numer, int __denom)
      |              ^~~
a.cc: In function 'int main()':
a.cc:29:20: error: cannot convert 'const div_t' to 'int' in initialization
   29 |         int v = max(div(A, a[i]), div(T, t[i]));
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                    |
      |                    const div_t
In file included from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = div_t]':
a.cc:29:20:   required from here
/usr/include/c++/14/bits/stl_algobase.h:262:15: error: no match for 'operator<' (operand types are 'const div_t' and 'const div_t')
  262 |       if (__a < __b)
      |           ~~~~^~~~~
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
  448 |     operator<(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algobase.h:262:15: note:   'const div_t' is not derived from 'const std::reverse_iterator<_Iterator>'
  262 |       if (__a < __b)
      |           ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  493 |     operator<(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algobase.h:262:15: note:   'const div_t' is not derived from 'const std::reverse_iterator<_Iterator>'
  262 |       if (__a < __b)
      |           ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1694 |     operator<(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algobase.h:262:15: note:   'const div_t' is not derived from 'const std::move_iterator<_IteratorL>'
  262 |       if (__a < __b)
      |           ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
 1760 |     operator<(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algobase.h:262:15: note:   'const div_t' is not derived from 'const std::move_iterator<_IteratorL>'
  262 |       if (__a < __b)
      |           ~~~~^~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
 1045 |     operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1045:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algobase.h:262:15: note:   'const div_t' is not derived from 'const std::pair<_T1, _T2>'
  262 |       if (__a < __b)
      |           ~~~~^~~~~