No.443 GCD of Permutation
問題文最終更新日: 2026-06-26 06:07:35
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Back to the original
yukicoder contest 153
(順位表)
の他の問題:
Problem Statement
You are given a positive integer $N$. Let $S$ be the set of all positive integers that can be formed by rearranging the digits of $N$.
Find the greatest common divisor $G$ of all elements of $S$.
Input
$N$
$1\leq N \leq 10^{10000}$
Output
$G$
Output the greatest common divisor $G$ of all elements of $S$. Do not forget the newline.
Sample
Sample 1
Input
444
Output
444
However the digits of $444$ are rearranged, the result is $444$, so $S=\{444\}$ and the greatest common divisor is $444$.
Sample 2
Input
900
Output
9
$0$ is also subject to rearrangement. Any $0$s that end up at the front after rearranging are ignored. In this sample, $S=\{9,90,900\}$. The greatest common divisor of these 3 integers is $9$.
Sample 3
Input
444888
Output
36
Sample 4
Input
20160101
Output
1
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
🍡yurahuna