Last active
July 21, 2021 17:40
-
-
Save uchidama/f88f93c629dc611cf99ddf78ff7362b4 to your computer and use it in GitHub Desktop.
AtCoder Beginner Contest 165 [ D - Floor Function ] https://atcoder.jp/contests/abc165/tasks/abc165_d
This file contains hidden or 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
''' | |
[問題] | |
https://atcoder.jp/contests/abc165/tasks/abc165_d | |
[解説] | |
https://blog.hamayanhamayan.com/entry/2020/05/02/225827 | |
''' | |
import sys | |
sys.setrecursionlimit(10 ** 6) # 再帰上限の引き上げ | |
input = sys.stdin.readline | |
INF = 2 ** 63 - 1 | |
A, B, N = map(int, input().split()) | |
#print("A:B:N:",A,B,N) | |
def f(x): | |
return (A*x//B) - A*(x//B) | |
''' | |
#表示してみると、mod Bでループしていることがわかる | |
for i in range(N*10+1): | |
print(i, f(i)) | |
''' | |
# 最大値はx = Nか、x = B-1のどちらか | |
num1 = f(N) | |
num2 = 0 | |
if (B-1) <= N: | |
num2 = f(B-1) | |
ans = max(num1, num2) | |
print(ans) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment