ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1142. Отношения

Phan Hoài Nam (Harvey Nash) Some hint for you (Very exciting problem, although it's easy at the first time). [1] // Задача 1142. Отношения 4 мар 2011 20:28
Let a be the number of objects.
Let b be the number of objects in a group.
Let A[a] is the number of permutations of a objects ( A[2] = 2, A[3] = 2*3, A[4] = 2*3*4...)

So:
f[a][b] is the number of groups with b objects.
You have the formula:
f[a][b] = f[a-1][b] * b + f[a-1][b-1];
And the result = f[n][1] * A[1] + f[n][2] * A[2] + ... + f[n][3] * A[3]

A group is formed by equal objects in a relation.
For example:
a = b < c = d (2 groups ab and cd)
a = b < c < d (3 groups ab, c and d)
...

I think when N is increased to 1000, everyone will solve it by DP or maths, not cheat :-)

thank you for your idea.
I had learnt a lot from yours.