A. I'm bored with life

Codeforces
IDCF822A
Time1000ms
Memory256MB
Difficulty
implementationmathnumber theory
English · Original
Chinese · Translation
Formal · Original
Holidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university of her dreams which is located in a town Pavlopolis. It's well known that universities provide students with dormitory for the period of university studies. Consequently Noora had to leave Vičkopolis and move to Pavlopolis. Thus Leha was left completely alone in a quiet town Vičkopolis. He almost even fell into a depression from boredom! Leha came up with a task for himself to relax a little. He chooses two integers _A_ and _B_ and then calculates the greatest common divisor of integers "_A_ factorial" and "_B_ factorial". Formally the hacker wants to find out GCD(_A_!, _B_!). It's well known that the factorial of an integer _x_ is a product of all positive integers less than or equal to _x_. Thus _x_! = 1·2·3·...·(_x_ - 1)·_x_. For example 4! = 1·2·3·4 = 24. Recall that GCD(_x_, _y_) is the largest positive integer _q_ that divides (without a remainder) both _x_ and _y_. Leha has learned how to solve this task very effective. You are able to cope with it not worse, aren't you? ## Input The first and single line contains two integers _A_ and _B_ (1 ≤ _A_, _B_ ≤ 109, _min_(_A_, _B_) ≤ 12). ## Output Print a single integer denoting the greatest common divisor of integers _A_! and _B_!. [samples] ## Note Consider the sample. 4! = 1·2·3·4 = 24. 3! = 1·2·3 = 6. The greatest common divisor of integers 24 and 6 is exactly 6.
假期结束了。在黑客 Leha 的帮助下,Noora 成功进入了她梦想中的大学——位于 Pavlopolis 镇的大学。众所周知,大学会为学生提供住宿,直至学业结束。因此,Noora 必须离开 Vičkopolis,搬往 Pavlopolis。于是 Leha 被完全独自留在了宁静的 Vičkopolis 镇,他几乎因无聊而陷入抑郁! 为了放松一下,Leha 给自己出了一个任务。他选择两个整数 $A$ 和 $B$,然后计算整数 "$A$ 阶乘" 和 "$B$ 阶乘" 的最大公约数。形式上,黑客希望求出 $\text{GCD}(A!,\ B!)$。众所周知,一个整数 $x$ 的阶乘是所有小于等于 $x$ 的正整数的乘积。因此 $x! = 1\cdot2\cdot3\cdot\ldots\cdot(x-1)\cdot x$。例如 $4! = 1\cdot2\cdot3\cdot4 = 24$。回忆一下,$\text{GCD}(x,\ y)$ 是能同时整除 $x$ 和 $y$(无余数)的最大正整数 $q$。 Leha 已经学会了高效解决这个问题。你也能不逊色地完成它,对吧? 第一行且仅一行包含两个整数 $A$ 和 $B$ $(1 \leq A,\ B \leq 10^9,\ \min(A,\ B) \leq 12)$。 请输出一个整数,表示整数 $A!$ 和 $B!$ 的最大公约数。 考虑样例。 $4! = 1\cdot2\cdot3\cdot4 = 24$。$3! = 1\cdot2\cdot3 = 6$。整数 $24$ 和 $6$ 的最大公约数恰好是 $6$。 ## Input 第一行且仅一行包含两个整数 $A$ 和 $B$ $(1 \leq A,\ B \leq 10^9,\ \min(A,\ B) \leq 12)$。 ## Output 请输出一个整数,表示整数 $A!$ 和 $B!$ 的最大公约数。 [samples] ## Note 考虑样例。$4! = 1\cdot2\cdot3\cdot4 = 24$。$3! = 1\cdot2\cdot3 = 6$。整数 $24$ 和 $6$ 的最大公约数恰好是 $6$。
**Definitions** Let $ A, B \in \mathbb{Z} $ with $ 1 \leq A, B \leq 10^9 $ and $ \min(A, B) \leq 12 $. Let $ n! = \prod_{i=1}^{n} i $ denote the factorial of $ n $. **Constraints** $ \min(A, B) \leq 12 $ **Objective** Compute $$ \gcd(A!, B!) $$
Samples
Input #1
4 3
Output #1
6
API Response (JSON)
{
  "problem": {
    "name": "A. I'm bored with life",
    "description": {
      "content": "Holidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university of her dreams which is located in a town Pavlopolis. It's well known that universities provide stud",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF822A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Holidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university of her dreams which is located in a town Pavlopolis. It's well known that universities provide stud...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "假期结束了。在黑客 Leha 的帮助下,Noora 成功进入了她梦想中的大学——位于 Pavlopolis 镇的大学。众所周知,大学会为学生提供住宿,直至学业结束。因此,Noora 必须离开 Vičkopolis,搬往 Pavlopolis。于是 Leha 被完全独自留在了宁静的 Vičkopolis 镇,他几乎因无聊而陷入抑郁!\n\n为了放松一下,Leha 给自己出了一个任务。他选择两个整数 $A...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ A, B \\in \\mathbb{Z} $ with $ 1 \\leq A, B \\leq 10^9 $ and $ \\min(A, B) \\leq 12 $.  \nLet $ n! = \\prod_{i=1}^{n} i $ denote the factorial of $ n $.\n\n**Constraints**  \n$ \\min(A, B)...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments