Submission #40404533


Source Code Expand

import math
 
N, M = map(int, input().split())
 
if N * N < M:
  print(-1)
  exit()
if M <= N:
  print(M)
  exit()
  
X = float("inf")
rootM = int(M ** (1 / 2))
for a in range(math.ceil(M / N), rootM + 2):
  b, m = divmod(M, a)
  if m == 0:
    print(M)
    exit()
  X = min(X, a * (b + 1))
  
print(X)  

Submission Info

Submission Time
Task D - M<=ab
User arakaki_tokyo
Language PyPy3 (7.3.0)
Score 400
Code Size 324 Byte
Status AC
Exec Time 78 ms
Memory 63528 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 56
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All crandom_00.txt, crandom_01.txt, crandom_02.txt, crandom_03.txt, crandom_04.txt, crandom_05.txt, crandom_06.txt, crandom_07.txt, crandom_08.txt, crandom_09.txt, example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, impossible_00.txt, impossible_01.txt, impossible_02.txt, impossible_03.txt, impossible_04.txt, just_00.txt, just_01.txt, just_02.txt, just_03.txt, just_04.txt, just_05.txt, just_06.txt, nlarge_00.txt, nlarge_01.txt, nlarge_02.txt, nlarge_03.txt, nlarge_04.txt, nlarge_05.txt, nlarge_06.txt, nlarge_07.txt, nlarge_08.txt, over_00.txt, over_01.txt, over_02.txt, over_03.txt, over_04.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt
Case Name Status Exec Time Memory
crandom_00.txt AC 65 ms 60852 KiB
crandom_01.txt AC 55 ms 61452 KiB
crandom_02.txt AC 52 ms 60976 KiB
crandom_03.txt AC 51 ms 61608 KiB
crandom_04.txt AC 51 ms 61484 KiB
crandom_05.txt AC 50 ms 60856 KiB
crandom_06.txt AC 60 ms 63224 KiB
crandom_07.txt AC 52 ms 60976 KiB
crandom_08.txt AC 51 ms 61092 KiB
crandom_09.txt AC 52 ms 61124 KiB
example_00.txt AC 50 ms 61684 KiB
example_01.txt AC 53 ms 60948 KiB
example_02.txt AC 50 ms 61472 KiB
hand_00.txt AC 52 ms 61640 KiB
hand_01.txt AC 50 ms 61012 KiB
hand_02.txt AC 52 ms 61432 KiB
hand_03.txt AC 54 ms 61056 KiB
hand_04.txt AC 49 ms 61212 KiB
hand_05.txt AC 51 ms 61136 KiB
hand_06.txt AC 52 ms 61020 KiB
impossible_00.txt AC 50 ms 61292 KiB
impossible_01.txt AC 51 ms 61236 KiB
impossible_02.txt AC 56 ms 60972 KiB
impossible_03.txt AC 52 ms 60952 KiB
impossible_04.txt AC 51 ms 61028 KiB
just_00.txt AC 50 ms 61476 KiB
just_01.txt AC 53 ms 61648 KiB
just_02.txt AC 51 ms 61468 KiB
just_03.txt AC 54 ms 63504 KiB
just_04.txt AC 53 ms 63152 KiB
just_05.txt AC 51 ms 61440 KiB
just_06.txt AC 54 ms 61504 KiB
nlarge_00.txt AC 50 ms 61388 KiB
nlarge_01.txt AC 49 ms 61484 KiB
nlarge_02.txt AC 52 ms 61288 KiB
nlarge_03.txt AC 50 ms 61504 KiB
nlarge_04.txt AC 78 ms 63252 KiB
nlarge_05.txt AC 53 ms 61732 KiB
nlarge_06.txt AC 49 ms 61756 KiB
nlarge_07.txt AC 71 ms 63136 KiB
nlarge_08.txt AC 72 ms 63528 KiB
over_00.txt AC 55 ms 61552 KiB
over_01.txt AC 52 ms 61500 KiB
over_02.txt AC 52 ms 61500 KiB
over_03.txt AC 51 ms 61632 KiB
over_04.txt AC 50 ms 61472 KiB
random_00.txt AC 51 ms 61488 KiB
random_01.txt AC 50 ms 61388 KiB
random_02.txt AC 49 ms 61472 KiB
random_03.txt AC 51 ms 61732 KiB
random_04.txt AC 52 ms 61604 KiB
random_05.txt AC 55 ms 61424 KiB
random_06.txt AC 52 ms 61636 KiB
random_07.txt AC 49 ms 61616 KiB
random_08.txt AC 56 ms 63412 KiB
random_09.txt AC 57 ms 63496 KiB