Created
September 21, 2016 13:56
-
-
Save yurahuna/bb48cff2ba12ba5a39bd85680f3f1697 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
signed main() { | |
std::ios::sync_with_stdio(false); | |
std::cin.tie(0); | |
int A, B, N; | |
cin >> A >> B >> N; | |
int ans = inf; | |
rep2(a, 1, N + 1) { | |
rep2(b, 1, N + 1) { | |
if (B % b == 0) { | |
ans = min(ans, abs(A - a * (B / b))); | |
} | |
} | |
} | |
cout << ans << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment