Problem: Given are integers A, B, and N.  Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non- negative integer x not greater than N.  Here floor(t) denotes the greatest integer not greater than the real number t.

Submission attempts (in order):

from sys import stdin
input = stdin.readline

a,b,n = map(int,input().split())

maxpoint = 0

for i in reversed(range(n+1)):
    tmp = int((a * i) / b)  - a * int(i/b) 
    if i % (b-1) == 0 and b > 1:
        print(tmp) 
        exit()
    maxpoint = max(tmp,maxpoint)

print(maxpoint)





from sys import stdin
input = stdin.readline

a,b,n = map(int,input().split())

maxpoint = 0

for i in reversed(range(n+1)):
    tmp = int((a * i) / b)  - a * int(i/b) 
    if b > 1:
        if i % (b-1) == 0 :
            print(tmp) 
            exit()
    elif b == 1:
        print(0)
        exit()
    maxpoint = max(tmp,maxpoint)
print(maxpoint)




from sys import stdin
input = stdin.readline

a,b,n = map(int,input().split())
maxpoint = 0

if b > n  :
    tmp = int((a * n) / b)  - a * int(n/b) 
    maxpoint = max(tmp,maxpoint)
    print(0)
elif b == n:
    maxpoint = 0
else:
    tmp = int((a * n) / b)  - a * int(n/b) 
    k = int(n/b)*b -1
    t1 =  int((a * k) / b)  - a * int(k/b) 
    maxpoint = max(t1,tmp)
    
    #     t1 =  int((a * i) / b)  - a * int(i/b) 
    #     if b > 1:
    
    #             print(maxpoint) 
    #             exit()
    #     elif b == 1:
    #         print(0)
    #         exit()
    #     if t1 > maxpoint:
    #         maxpoint = t1
       
    
    # print(tmp)
   
    # print(k)
    
    # maxpoint = max(tmp,k)
    

print(maxpoint)




from sys import stdin
input = stdin.readline

a,b,n = map(int,input().split())
maxpoint = 0

if b > n  :
    tmp = int((a * n) / b)  - a * int(n/b) 
    maxpoint = max(tmp,maxpoint)
    print('g')
    exit()
elif b == n:
    maxpoint = 0
else:
    tmp = int((a * n) / b)  - a * int(n/b) 
    k = int(n/b)*b -1
    t1 =  int((a * k) / b)  - a * int(k/b) 
    maxpoint = max(t1,tmp)
    
    #     t1 =  int((a * i) / b)  - a * int(i/b) 
    #     if b > 1:
    
    #             print(maxpoint) 
    #             exit()
    #     elif b == 1:
    #         print(0)
    #         exit()
    #     if t1 > maxpoint:
    #         maxpoint = t1
       
    
    # print(tmp)
   
    # print(k)
    
    # maxpoint = max(tmp,k)
    

print(maxpoint)




from sys import stdin
input = stdin.readline

a,b,n = map(int,input().split())
maxpoint = 0

if b > n  :
    tmp = int((a * n) / b)  - a * int(n/b) 
    maxpoint = max(tmp,maxpoint)
    print('g')
elif b == n:
    maxpoint = 0
else:
    tmp = int((a * n) / b)  - a * int(n/b) 
    k = int(n/b)*b -1
    t1 =  int((a * k) / b)  - a * int(k/b) 
    maxpoint = max(t1,tmp)
    
    #     t1 =  int((a * i) / b)  - a * int(i/b) 
    #     if b > 1:
    
    #             print(maxpoint) 
    #             exit()
    #     elif b == 1:
    #         print(0)
    #         exit()
    #     if t1 > maxpoint:
    #         maxpoint = t1
       
    
    # print(tmp)
   
    # print(k)
    
    # maxpoint = max(tmp,k)
    

print(maxpoint)




from sys import stdin
input = stdin.readline

a,b,n = map(int,input().split())
maxpoint = 0

if b > n :
    for i in range(n+1):
        tmp = int((a * i) / b)  - a * int(i/b) 
        maxpoint = max(tmp,maxpoint)
        print(0)
        
else:
    for i in reversed(range(n+1)):
        c += 1
        tmp = int((a * i) / b)  - a * int(i/b) 
        if b > 1:
            if i % (b-1) == 0 :
                maxpoint = max(tmp,maxpoint)
                print(maxpoint) 
                exit()
        elif b == 1:
            print(0)
            exit()
        maxpoint = max(tmp,maxpoint)

print(maxpoint)



from sys import stdin
input = stdin.readline
 
a,b,n = map(int,input().split())
maxpoint = 0
 
if b > n  :
    tmp = int((a * n) / b)  - a * int(n/b) 
    maxpoint = max(tmp,maxpoint)
else:
    k = int(n/b)*b -1
    maxpoint =  int((a * k) / b)  - a * int(k/b) 
    if b == 1:
        maxpoint = 0
 
print(maxpoint)

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Accepted