I did this too :(. Maybe I am not getting it, but I tried and I picked up 997. Since M<=5, I don't know which primes to pick. the primes which have their squares less than 997 will give their squares...
Type: Posts; User: sc7
I did this too :(. Maybe I am not getting it, but I tried and I picked up 997. Since M<=5, I don't know which primes to pick. the primes which have their squares less than 997 will give their squares...
but , that's not the issue, my problem is with guessing the prime number in such a huge range. I don't know which numbers to give the computer and then get x^2%P, I can ask this M times(less than...
I am not trying to get my homework done here. Just needed help in a topic which I am weak in. That's why I added in the end to guide me. I have been trying out this problem for quite a while now, and...
If anyone could help even for 1st Question, it would be very helpful.
(1st question)
We need to guess a Prime number between 2 to 10^9(inclusive) in M questions.
Here's how it works:
- We can give the computer a number x(1 to 10^9).the computer replies with x^2%P....
I see... you have a lot of frustration in your life, and since, you are too much of a coward to deal with them, you go online and try to undermine other's work, cool good for you.. and who says...
I need some help in solving this substring problem am dealing with, here's the problem:
Q:
Find the longest substring in a string(that we input) that contains at least one character who's...
can't see whtats the wrong output, online site doesn't show that, just correct or wrong, some of my test cases passes but some don't:
Algo:
Look for two longest streaks of 1s, for rotation keep a...
I am not getting segmentation error now, just the implementation is wrong still..some test cases are working perfectly while others giving wrong answer
never put it on you dude, instead thanked you. cool. good chat.
Yes, maybe I don't know C++ ... but isn't what this forum is for, making others understand what you're trying to do, maybe I am a little frustrated and not thinking straight coz I have been banging...
I am finding it hard to understand your code, why are you inputting bit twice ?? whats init ?? is that checking if array[0] and array[n-1] both have 1s ?what is place function doing ??
I really...
@tabstop, lol, yes thats correct, I finally got down and learned how to use a debugger, it helped.
Still my code is giving some testcases as wrong and some correct...
I found the error its in the while loop
while(arr[i]==1) //should contain i<n, Still am getting some correct testcases, some wrong, there is still something wrong(with my implementation)
What I meant to say is that this could handle large inputs, but don't know if I am going out of bounds somewhere, or something like that ??
2
3
3 is the expected output..
I have checked with all 0s all 1s and 101010 , it works fine with all in my personal IDE, but shows SIGSEGV error on online one
example testcase:
5 5 3
1 1 0 1 1
?!?!?
output:
2
3
3
The test cases that got segmentation error are not shown,
Following is the code to a problem I have been doing over course of 1 week , I came close, 1subtask(With huge input) is passing , but other testcases are showing Runtime error(SIGSEGV)(Segementation...
Sorry for messaging you privately and posting in other's thread, but I was desperate to get my code right I think...
I did provide proper naming and indentation and the algorithm is already...
@john.c can you please debug this ??
So I coded the way you told, it did pass the limit, but is giving Segmentation fault error, and I can't seem to find the error :(
int streak_1_head,streak_1_tail,streak_2_head,streak_2_tail;
...
How?? the result is calculated arithmetically, I need to find the max run of 1's anyhow for each query and check at the end whether it is smaller than or greater than k, and return my result...
I understand why you are emphasising so much on the k value, in the beginning, even I thought that the answer is very dependent on k, then realised, no it's an idiotic way to make this problem unique...
No, please refer to the sample input and output on the page, It clearly tells with an explanation if your array is like [1,1,1,1,0] and k=3, then the largest subsequence, i.e, from i=0 till...