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

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

Here we have to print the value of 'x*j'. This problem was asked in my coding interview (Jaguar: Software Profile). Constraints were not mentioned in the problem.

This is the solution that I came up with : https://ideone.com/Uvqvqf Code Explanation: I used a brute-force approach where I found all possible strings consisting of only 4 and 0 using bit-manipulation. Then I searched for the first number which gives : (number % x == 0) true.

It works for small inputs only. Please help me out with this problem and tell me if my approach is correct because I am unable to find any similar problem anywhere else. If possible suggest a similar problem so I can try my approach on that problem to see if it works or not.

Hints are also welcomed.

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

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

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

I am getting wrong answer (on test 15) for this problem : 687A - NP-Hard Problem

Here is my code : 51436363

Solution description : I have used concept of bipartitie graphs. If the graph is a bipartitie graph then solution is possible otherwise not. I have made a vector "dist" in which i have stored the distance of vertices from the source vertex. All the vertices at "odd" distance from the source go to vector "v2" and those with "even" distance go to vector "v1".

I have just started to learn graph theory so please tell me what is wrong with the logic and code.

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

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