Блог пользователя arjitkansal

Автор arjitkansal, история, 5 лет назад, По-английски

Just realized this fact, but need confirmation if I'm not missing anything (Although it got AC on a problem :P) because it looks simple AF!!

Every integer can be represented as one of the following-> 6k, 6k+1, 6k+2, 6k+3, 6k+4, 6k+5.

6k -> divisible by 6 (Hence not prime)

6k+1 -> Prime

6k+2 -> Or 2*(3k+1); Hence divisible by 2 (Not prime)

6k+3 -> Divisible by 3 (Not prime)

6k+4 -> Divisible by 2 (Not prime)

6k+5 -> Prime

Therefore, each prime number (>3) can be represented in either 6k+1 form or 6k+5 form.

bool isPrime(int x) {
    if (x==1) return false;
    if (x==2 || x==3) return true;

    //If (x == 6k+1)
    int k = (x-1)/6;
    if (x == (6*k+1)) return true;

    //If (x == 6k+5)
    k = (x-5)/6;
    return (x == (6*k+5));
}

Полный текст и комментарии »

  • Проголосовать: нравится
  • -62
  • Проголосовать: не нравится

Автор arjitkansal, история, 6 лет назад, По-английски

This is to reach the concerned people out there.

Actually the upcoming round scheduled this Saturday i.e. March 30, 2019 at 17.05 GMT (22.35 IST) will become quite hectic to participate in as the Codechef March 2019 Lunchtime will get over just 5 min before it. Please if possible, it should be rescheduled by atleast half an hour.

I don't know whom to tag so I wrote this on blog.

Полный текст и комментарии »

  • Проголосовать: нравится
  • -14
  • Проголосовать: не нравится

Автор arjitkansal, история, 6 лет назад, По-английски

Hello everyone!

I'm looking for an 2-months internship during this summer in 2019. Like many others, even I dream of getting into Google or Facebook but anything where my competitive coding skills can prove to be useful.

Currently, I'm studying 'Instrumentation & Control Engineering' but seriously not interested in its core. I heard from some people that Google and Facebook has some internship roles related to competitive coding as well, but I couldn't find any such on their websites. If anyone has any idea of them, please tell me about them.

And if anyone can refer me, kindly let me know. I'll send my resume.

That would be more than just a help :)

Полный текст и комментарии »

  • Проголосовать: нравится
  • -27
  • Проголосовать: не нравится

Автор arjitkansal, история, 6 лет назад, По-английски

It has been months, I've not able to think of any solution to solve this problem "Component Tree".

link to the problem

As this is Gym Problem, I'm not able to look for the solutions. It would be a great help if someone can provide me with the hints to solve the problem.

Thanks :)

Полный текст и комментарии »

  • Проголосовать: нравится
  • +7
  • Проголосовать: не нравится

Автор arjitkansal, история, 6 лет назад, По-английски

It has been almost 5 hours and more than 5 pages of submissions in the queue. It's really annoying.

Does anybody know, When it is expected to recover ?

Полный текст и комментарии »

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

Автор arjitkansal, история, 6 лет назад, По-английски

This doubt is related to the problem :-

Xenia and Tree

Centroid Decomposition Approach.

This is the link to my solution.

What I did to calculate distances of each node to its parent in centroid tree was while making the Centroid tree, I was storing the distances of current node in the DFS with the previous centroid in the Centroid Tree in a map.

And after the DFS, if distances of some nodes to it's indirect parents are left, I updated them by the formula

dis[current_node][parent of indirect parent]=dis[current_node][indirect parent]+dis[indirect parent][parent of indirect parent];

But I'm getting a WA at test case 12.

Can someone please help me debug this approach ?

I'm sure there is no implementation problem with centroid tree transformation as I used the same code in another problem, there it worked. Only issue can be there in calculation of the distances.

Полный текст и комментарии »

  • Проголосовать: нравится
  • -6
  • Проголосовать: не нравится