._JO_.'s blog

By ._JO_., history, 16 months ago, In English

Lately, i was solving this problem and the editorial provide this solution

can someone tell me what's the time complexity of the getDivisors()?

I think it's 2^n pick-or-leave that's why I wonder !

if a, b like 2^29 it will generate all possibilities which will not fit in time!


~~~~~ vector<int> divisors; void getDivisors(int ind = 0, int res = 1) { if (ind == (int) factors.size()) { divisors.push_back(res); return; } for (int i = 0; i <= factors[ind].second; i++) { getDivisors(ind + 1, res); res *= factors[ind].first; } }

~~~~~

Am I wrong ?

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By ._JO_., history, 17 months ago, In English

Hello Guys

For these types of problems under which tag are they and how to practice it?

https://codeforces.net/contest/1453/problem/B

and if any one has a link for some problems to master it, I'll be grateful

thanks in advance

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it