ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1748. The Most Complex Number

Algo
Posted by Baurzhan 26 Jan 2010 11:48
Can somebody tell me how solve this problem?
Re: Algo
Posted by l@mho 26 Jan 2010 13:12
what is test19? maybe some wrong in test19
Re: Algo
Posted by SEU_AKATSUKI 31 Jan 2010 18:12
It can be solved using backtracking :)
Re: Algo
Posted by Timur_Bekibaev 31 Jan 2010 21:14
Баур, эта задача решатся "в лоб"
Re: Algo
Posted by Igor Mihajlovic 3 Apr 2010 15:39
can anyone tell me what algo for this problem
Re: Algo
Posted by Artem Khizha [DNU] 28 Jul 2010 17:25
> can anyone tell me what algo for this problem
I can, though my approach wasn't so easy.

I used precalculations. My way is to generate all pairs (N, P), where P = 1, 2, ... - complexity of number and N - such minimal number, that has exactly P divisors.

How to do this with such large inputs? Solve another problem: recover N, if you know P. I used backtrack there, but still I'm wondering whether there is a more beautiful way.
Re: Algo
Posted by Nic Roets 5 Nov 2011 14:52
First I wrote a recursive function that tries all v=2^a * 3^b * 5^c * 7^d * 11^e * ... with a>=b>=c>=... It generates +- a million possibilities and takes around 300 ms for each case. So I got TLE with 100 cases.

Then I wrote code that reads all the n values and sort them. Then I call the recursive function with 10^18. I added a binary search to it that finds the smallest n greater or equal to v and update the best result for it. When the recursive function returns, I update the results for the larger values of n with the smaller results. And then I output the results in the same order as the input.

All in less that 50 lines of C++.
Re: Algo
Posted by SamGTU7_Kareva Nadezhda Vladimirovna 12 Jun 2013 23:56
The list of high high composite numbers (it is their scientific name) is here http://oeis.org/A002182/b002182.txt
Article is here http://en.wikipedia.org/wiki/Highly_composite_number
Re: Algo
Posted by Keshav Sharma 22 Jun 2019 21:25
I think u can safely assume that that there is no number with power>10
so 10>=a>=b>=c>=d... and now I think u will  get AC without doing anything else.
Plus small small optimisation.. like breaking at a point if current no. > query(which is obvious to do so) and other such small small optimisation will do.
Other thing is to check if ur current no. doesnt exceed the long long range (u can only check by using log()...)