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

Обсуждение задачи 1560. Elementary Symmetric Functions

Why p is prime?
Послано Dirichlet 23 сен 2007 18:02
Is it possible to use somehow that p is prime?
My AC solution doesn't use this fact, but I'm wondering is there a simpler way to solve this task.
What complexity of your solution?
Послано Victor Barinov (TNU) 23 сен 2007 22:12
Re: What complexity of your solution?
Послано Dirichlet 24 сен 2007 02:51
Complexity is (M + N) * log N, where N is a size of the array and M is a number of queries
Re: What complexity of your solution?
Послано Denis Koshman 15 авг 2008 16:24
I needed primality of 'p' when I calculated S(K) from sums of powers for Ai. I needed to divide by 2, 6 or 24 in the end. Primality plays important role when you find inverse of these divisors modulo 'p'. Also the fact that S>1000 was also convenient fact because some multiplications would turn to zero for quite small p.
Re: What complexity of your solution?
Послано luckysundog 10 сен 2011 20:09
This problem is named "Elementary Symmetric Functions".
There is formula (by Newton) that gives relation between elementary symmetric polynomials and "power sums" (that are symmetric too). Formula used division that can be done in general case only by prime modulo.

But it can be solved without knowing any special about these polynomials. In this case solution doesn't need the primality of P. And then we have a data structure problem only, not number theoretical :)  I used interval tree and memoization of sums on subsegments. And still the 4 seconds limitation is too large.

upd: Fenwick tree is better ;)

Edited by author 10.09.2011 23:40
Re: What complexity of your solution?
Послано Artyom 3 дек 2021 20:36
I understand how to solve the problem with combinatoric formula and 4 segment trees, can you please explain the second way?