时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒 空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M 64bit IO Format: %lld
题目描述
Given three positive integers , you should find two non-negative integers that and minimize . Print the minimum . Here will be given in format where denotes the primary factor and its power respectively.
Hint: you can use "__int128_t" in C++ to handle 128-bit integers.
输入描述:
The first line contains one integer .
Following lines each contains two integers .
Following one line contains two integers , where .
It's guaranteed that s are all primes and .
输出描述:
Output one line only containing one integer, denoting the answer.