You are not logged in. Please login at www.codechef.com to post your questions!

×

DEBNPRM - Editorial

Problem link:

Contest , Practice

Setter: Souradeep Paul

Tester: Debjit Datta

Difficulty:

Easy

Prerequisites:

Dynamic Programming, Prime-sieve

Explanation:

Given a number, we have to find if its prime. If not we add the first prime number to it and check if its prime and then the second and so on until the sum becomes prime.

We use prime sieve and store all the prime numbers as false in a boolean array and composite numbers as true. Along with that we keep a list of all prime numbers upto 10^7. We check if the given number is prime and if not, we add the first number from the list to it and check again. The process goes on until we find a prime number.

Author’s and Tester’s Solution:

Author’s solution is here

Tester's solution is here

This question is marked "community wiki".

asked 02 Apr '18, 23:13

debjitdbb's gravatar image

4★debjitdbb
534
accept rate: 0%

wikified 02 Apr '18, 23:14

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×2,085
×301
×12

question asked: 02 Apr '18, 23:13

question was seen: 150 times

last updated: 02 Apr '18, 23:14