Created
February 7, 2019 01:04
-
-
Save task4233/353793c3588c494c034bbb20cccacd9b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
using int64 = int64_t; | |
int f(int x, int y){ | |
int mx = max(x, y); | |
int mn = min(x, y); | |
if (mx == mn) return x; | |
return f(mn, mx-mn) + 2 * mn; | |
} | |
int main(){ | |
int n, x; | |
cin >> n >> x; | |
int ans = x + (n-x) + f(x, n-x); | |
cout << ans << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment