Help with error

prob: https://codeforces.com/problemset/problem/26/A

code: https://ide.codingblocks.com/s/452827

the sieve part is working correctly but not getting the correct answer

hello @raghav007

in prime vector u are pushing p[i] but i think u need to push i.

also what u are trying here

	for(int i = prime.size() - 1; i >= 0; i--){
		if(i - 2 >= 0){
		if(prime[i] == prime[i-1] + prime[i-2] + 1){
			count++;
		}
	}
	}

once check ur code link , it is printing yes no , but in te problem it is asked to print the count

https://codeforces.com/problemset/problem/17/A
sorry this is the correct problem link

a) make ur vector p of size n+1 . becuase u r preparing sieve upto index n.

b) push i in place of p[i] in ur prime vector
c) prime[i] == prime[i-1] + prime[i-2] + 1 this is wrong.
question says prime+ next prime +1 must be a prime no other constraint.

getting run time error on one test case 296 19 is the input


	for(int i = prime.size() - 1; i >= 1; i--){
		if(p[(prime[i] + prime[i-1] + 1)] == 1){
		count++;
			
	}

here first check (prime[i] + prime[i-1] + 1) <=n and then other condition

thanks it got accepted

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.