AtCoder Grand Contest 044
F
Name-Preserving Clubs
AtCoder
未评级
原题
← E→
翻译中…

Problem Statement

翻译中…

There are $N$ people (with different names) and $K$ clubs. For each club you know the list of members (so you have $K$ unordered lists). Each person can be a member of many clubs (and also $0$ clubs) and two different clubs might have exactly the same members. The value of the number $K$ is the minimum possible such that the following property can be true for at least one configuration of clubs. If every person changes her name (maintaining the property that all names are different) and you know the new $K$ lists of members of the clubs (but you don't know which list corresponds to which club), you are sure that you would be able to match the old names with the new ones.

翻译中…

Count the number of such configurations of clubs (or say that there are more than $1000$). Two configurations of clubs that can be obtained one from the other if the $N$ people change their names are considered equal.

翻译中…

Formal statement: A club is a (possibly empty) subset of $\{1,\dots, N\}$ (the subset identifies the members, assuming that the people are indexed by the numbers $1, 2,\dots, N$). A configuration of clubs is an unordered collection of $K$ clubs (not necessarily distinct). Given a permutation $\sigma(1), \dots, \sigma(N)$ of $\{1,\dots, N\}$ and a configuration of clubs $L=\{C_1, C_2, \dots, C_K\}$, we denote with $\sigma(L)$ the configuration of clubs $\{\sigma(C_1), \sigma(C_2), \dots, \sigma(C_K)\}$ (if $C$ is a club, $\sigma(C)=\{\sigma(x):\, x\in C\}$). A configuration of clubs $L$ is name-preserving if for any pair of distinct permutations $\sigma\not=\tau$, it holds $\sigma(L)\not=\tau(L)$.

翻译中…

You have to count the number of name-preserving configurations of clubs with the minimum possible number of clubs (so $K$ is minimum). Two configurations $L_1, L_2$ such that $L_2=\sigma(L_1)$ (for some permutation $\sigma$) are considered equal. If there are more than $1000$ such configurations, print $-1$.

翻译中…

Constraints

翻译中…
  • $2 \le N \le 2\cdot10^{18}$
翻译中…

Input

翻译中…

The input is given from Standard Input in the format

翻译中…

N

翻译中…

Output

翻译中…

If $ans$ is the number of configurations with the properties described in the statement, you should print on Standard Output

翻译中…

ans

翻译中…

If there are more than $1000$ such configurations, print $-1$.

翻译中…

样例

Input #1
2
Output #1
1
The value of $K$ is $1$ and the unique name-preserving configuration of clubs is $\{\{1\}\}$ (the configuration $\{\{2\}\}$ is considered the same).
Input #2
3
Output #2
1
The value of $K$ is $2$ and the unique (up to permutation) name-preserving configuration of clubs is $\{\{1\}, \{1, 2\}\}$.
Input #3
4
Output #3
7
The value of $K$ is $3$ and the name-preserving configurations of clubs with $3$ clubs are: - $\{\{1\}, \{2\}, \{1, 3\}\}$ - $\{\{1\}, \{1, 2\}, \{2, 3\}\}$ - $\{\{1, 2\}, \{1, 2\}, \{1, 3\}\}$ - $\{\{1\}, \{1, 2\}, \{1, 2, 3\}\}$ - $\{\{1\}, \{2, 3\}, \{1, 2, 4\}\}$ - $\{\{1, 2\}, \{1, 3\}, \{1, 2, 4\}$ - $\{\{1, 2\}, \{1, 2, 3\}, \{2, 3, 4\}\}$
Input #4
13
Output #4
6
Input #5
26
Output #5
-1
Input #6
123456789123456789
Output #6
-1
题目信息
题号
agc044_f
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。