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

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

suppose i have an array of n=5 elements say A={50,10,20,30,40}; when I pick i element from the array I can not pick i+1 element from the array. So how much value can I pick which will not exceed 100. So in this case I can pick maximum {50,40} which is less than 100. I tried to solve this using recursion, but i failed to do so because i can't establish any relation. How can I do so? Please help... I am new to recursion related topic.. TIA...

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

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

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

Suppose an array A[4]={3,2,10,4} is given. 2 player can pick a number from the front end of the array or last end of the array. if both player wants to make maximum score, what the maximum score first player can make?? in this case first player can make 13 {3,10}. obviously first player starts the picking. I tried this using recursion, but it does not give me correct ans. it gives 17. please help me which states i am missing... I am new to recursion.. TIA..

//here is my code
//initially value=0,left=0,right=n-1=3
int rec(int value,int left,int right)
{
    if(left>right or left>=n or right<0) return 0;
    int p1=value+rec(A[left],left+1,right);
    int p2=value+rec(A[right],left,right-1);
    int mx=max(p1,p2 );
    return mx;
}

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

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

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

this problem could be solved by quadratic roots. takes o(1). By i want to solve this using binary search. But i can't implement the logic in code correctly. please help. TIA...

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

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

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

Given a number n as input how to find the (all the primitive roots of n) % n if n is prime. please give me some hint how can i calculate the primitive roots.. TIA.

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

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

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

i know it isn't a good question to ask but i really need help to solve this problem or this kind of problem which involves probability. how can i solve this? pls give any good tutorial link where i can learn probability better... TIA.

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

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

Автор restart., 9 лет назад, По-английски

Can we solve spoj MULTQ3 using BIT? If yes then How?

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

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

Автор restart., 9 лет назад, По-английски

How could i solve this problem lightoj-1056 using binary search? i solved some problems using binary search. please anybody can help me what should be my strategy to solve this problem using binary search??

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

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

Автор restart., 9 лет назад, По-английски

lightoj-1062 in the category section it's showed that it can be solved by using binary search. how could i solve a geometry problem using binary search? i solved some problems using binary search. please anybody can help me what should be my strategy to solve this problem using binary search??

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

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

Автор restart., 10 лет назад, По-английски

how to generate next prime number for a given long interger n where n can be 0<=n<=10^18

for example if n is 10 then the next prime number is 11. how can i do it in 0.5 sec?? is there any number theory? pls give me any suggestion..

thanks in advance..

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

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