Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n, m, sum = 0;
- cin >> n >> m;
- n = n - 1;
- m = m - 1;
- int i = 1, k = 1;
- double tg1, tg2;
- tg1 = (double)n / m;
- while (i <= n && k <= m)
- {
- tg2 = (double)i / k;
- if (tg1 > tg2)
- {
- i += 1;
- sum += 1;
- }
- else
- {
- if (tg1 < tg2)
- {
- k += 1;
- sum += 1;
- }
- else
- {
- if (tg1 == tg2)
- {
- k += 1;
- i += 1;
- sum += 1;
- }
- }
- }
- }
- cout << sum << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement