305750: CF1085B. Div Times Mod
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Div Times Mod
题意翻译
## 题目描述 给定n,k(1≤n≤$10^6$,2≤k≤$10^3$) 已知i,ans $\in$ Z,S.T. i | n(1≤i)&&ans $\equiv$ i(mod k)&&ans / k == n / i 求ans的最小值 ## 输入输出格式 ### 输入格式: 一行,分别为n,k ### 输出格式: 一行,ans ## 输入输出样例 样例搬运过来就行了题目描述
Vasya likes to solve equations. Today he wants to solve $ (x~\mathrm{div}~k) \cdot (x \bmod k) = n $ , where $ \mathrm{div} $ and $ \mathrm{mod} $ stand for integer division and modulo operations (refer to the Notes below for exact definition). In this equation, $ k $ and $ n $ are positive integer parameters, and $ x $ is a positive integer unknown. If there are several solutions, Vasya wants to find the smallest possible $ x $ . Can you help him?输入输出格式
输入格式
The first line contains two integers $ n $ and $ k $ ( $ 1 \leq n \leq 10^6 $ , $ 2 \leq k \leq 1000 $ ).
输出格式
Print a single integer $ x $ — the smallest positive integer solution to $ (x~\mathrm{div}~k) \cdot (x \bmod k) = n $ . It is guaranteed that this equation has at least one positive integer solution.
输入输出样例
输入样例 #1
6 3
输出样例 #1
11
输入样例 #2
1 2
输出样例 #2
3
输入样例 #3
4 6
输出样例 #3
10