No.2593 Reorder and Mod 120
問題文最終更新日: 2023-12-21 06:20:05
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
Advent Calendar Contest 2023
(順位表)
の他の問題:
Problem Statement
You are given a string $S$ of length $N$. Consider the strings obtained by freely rearranging it, each viewed as a positive integer. Find how many different values are possible as the remainder when such an integer is divided by $120$.
Constraints
- $1 \leq N \leq 200000$
- $N$ is an integer
- $S$ is a string of length $N$ consisting only of digits between $1$ and $9$, inclusive
Input
$N$ $S$
Output
Print the answer on $1$ line. End the output with a newline.
Sample
Sample 1
Input
4 1221
Output
6The strings obtainable by rearranging
1221 are 1122,1212,1221,2112,2121,2211, and their remainders when divided by $120$ are $42,12,21,72,81,51$, respectively, so there are $6$ possible values.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。