restart.'s blog

By restart., history, 8 years ago, In English

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...

Full text and comments »

  • Vote: I like it
  • -5
  • Vote: I do not like it

By restart., history, 8 years ago, In English

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;
}

Full text and comments »

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

By restart., history, 9 years ago, In English

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...

Full text and comments »

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

By restart., history, 9 years ago, In English

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.

Full text and comments »

  • Vote: I like it
  • +5
  • Vote: I do not like it

By restart., history, 9 years ago, In English

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.

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it

By restart., 9 years ago, In English

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

Full text and comments »

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

By restart., 9 years ago, In English

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??

Full text and comments »

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

By restart., 9 years ago, In English

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??

Full text and comments »

  • Vote: I like it
  • -1
  • Vote: I do not like it

By restart., 10 years ago, In English

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..

Full text and comments »

  • Vote: I like it
  • +4
  • Vote: I do not like it