CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • All Contests
    • May Cook-Off
    • May Long 2012
    • April Cook-Off
  • DISCUSS
    • Wiki
    • Forums
    • Blog
    • Facebook
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
    • Event Calendar
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Compete » Algothika 2010 » The Next Prime

The Next Prime

Problem code: AD1

  • All Submissions

All submissions for this problem are available.

Prime number one of the simplest concept in our childhood and comes under the basics of maths . Now, cody's teacher has taught him the prime number concept and he decided to have some fun with it.

Cody knows that

" a prime number is a natural number that has exactly two distinct natural number divisors: 1 and itself"

Now, to check if he has learnt the prime number concept, he picked randomly a number n and if the number is prime then "YEAH" or else "NAA" and he has to find next 10 prime numbers

Input

The first line contains t, the number of test cases (1<=t<=10000). Followed by t lines which contain values of n(1 <=n <= 10^12)

Output

For every test case if n is a prime number print "YEAH" or else print "NAA" and print 10 successive prime numbers separated by a single space.

Example

Input:
3
19
63
23497.

Output:
YEAH

NAA
67 71 73 79 83 89 97 101 103 107

YEAH


Date: 2010-02-27
Time limit: 0.5s
Source limit: 50000
Languages: C C99 strict C++ 4.0.0-8 C++ 4.3.2 PAS gpc PAS fpc JAVA NICE JAR C# C#2 NEM ST ASM D FORT ADA BASH PERL PYTH RUBY LUA ICON PIKE PHP SCM guile SCM qobi LISP sbcl LISP clisp SCALA HASK ERL CAML CLPS PRLG WSPC BF ICK JS


  • Submit

Comments

  • Login or Register to post a comment.

please justify the SPACE

unpredictable0 @ 4 Mar 2010 06:19 PM

please justify the SPACE between ouputs of two cases .............

Hello Admin, I just submitted

rahul142 @ 4 Mar 2010 07:39 PM

Hello Admin, I just submitted my solution for this problem in JAVA. It seems to work fine with all the example test cases. But when I submitted it, I got an error which said Time Limit Exceeded. Is there any way to fix this ? Thanks in advance!!

- Rahul

@abhishek after every test

nirley.gupta @ 4 Mar 2010 08:05 PM

@abhishek

after every test case there should be an empty line

 

@rahul

please check your solution for all the numbers falling in the above mentioned range, not for the test cases

@rahul please check your

nirley.gupta @ 4 Mar 2010 08:06 PM

@rahul

please check your solution for all the numbers falling in the above mentioned range, not for the test cases only......

Please post all your doubts

nirley.gupta @ 4 Mar 2010 08:09 PM

Please post all your doubts here or mail it to algothika.algochallenge@gmail.com

ALGOTHIKA ORGANIZER

Nirley Gupta

Join us also on

nirley.gupta @ 4 Mar 2010 08:42 PM

Join us also on facebook

ALGOTHIKA

@admin please check the test

codegambler @ 5 Mar 2010 09:58 AM

@admin please check the test data. I am getting correct output for test case 1-50 and 999999999950-1000000000000

The test cases are

nirley.gupta @ 5 Mar 2010 10:42 AM

The test cases are right...............

Are u really serious with the

abhijith @ 5 Mar 2010 12:35 PM

Are u really serious with the time limit ?

10000 cases and n going upto 10^12 ?

kindly check the test cases

aarpit @ 5 Mar 2010 03:54 PM

kindly check the test cases

@admin kindly check ur all

unpredictable0 @ 5 Mar 2010 04:17 PM

@admin kindly check ur all data of test cases ..............

@admin plzzzzz check the

gourav_roy2009 @ 5 Mar 2010 07:41 PM

@admin plzzzzz check the input

The inputs are

tester17 @ 5 Mar 2010 08:19 PM

The inputs are correct.....

@abhijth

yes, we are serious and u can also see the problem solved in just 0.08 sec..

The inputs are

nirley.gupta @ 5 Mar 2010 08:21 PM

The inputs are correct.....

@abhijth

yes, we are serious and u can also see the problem solved in just 0.08 sec..

I am pretty sure there is

naughty @ 5 Mar 2010 09:28 PM

I am pretty sure there is something wrong with the test data. Can you please re-check ?

The test data is

nirley.gupta @ 5 Mar 2010 09:56 PM

The test data is right......

Someone has already solved it........

I thought, that someone is

naughty @ 5 Mar 2010 10:42 PM

I thought, that someone is Admin, whose source code is the judge solution :).

Still, Is everything alright with this one ? Output format, Input ?.

I think u r having real

nirley.gupta @ 5 Mar 2010 10:50 PM

I think u r having real problems with this question............

please mail me ur solution algothika.algochallenge@gmail.com

I have already mailed it long

naughty @ 5 Mar 2010 10:57 PM

I have already mailed it long time Back. Probably you din't check the mail ?

Got it, we will get back to u

nirley.gupta @ 5 Mar 2010 11:05 PM

Got it, we will get back to u asap.......

Okay, Thanks.

naughty @ 5 Mar 2010 11:06 PM

Okay, Thanks.

Can you please specify, if

kunaljain @ 5 Mar 2010 11:28 PM

Can you please specify, if there is a space at the end of the tenth prime number.

And also if there is a blank line after the last input.

@Yash The problem has been

nirley.gupta @ 6 Mar 2010 02:44 AM

@Yash

The problem has been rectified.....

 

@Kunal

there is a space after a tenth number and a blank line after the last output............

Hey, i have a doubt about the

rahul142 @ 6 Mar 2010 10:54 PM

Hey, i have a doubt about the output screen. Is this correct? Please tell me whether there is a space or line required or to be removed. Thanks!!

 

3

19

YEAH

 

63

NAA

67 71 73 79 83 89 97 101 103 107

 

23497

YEAH

@Rahul There should be a

nirley.gupta @ 6 Mar 2010 11:35 PM

@Rahul

There should be a single space between the numbers and there is an empty line after every test case....

your test case is write if these conditions are satisfied

 

For the above mentioned, it looks write

@Nirley : Can u please

rahul142 @ 6 Mar 2010 11:43 PM

@Nirley : Can u please provide some large test cases to check whether the code works properly for really big numbers.

@Rahul The test cases are

nirley.gupta @ 6 Mar 2010 11:54 PM

@Rahul

The test cases are right for this program, we have already received successful submissions for this problem and has been verified also......

hey.. m not able 2 submit my

shubhank @ 8 Mar 2010 01:33 AM

hey.. m not able 2 submit my code.. it is giving a compiler error,, dat class prm is public and thus be named as public.java!!

@Shubhank Please

nirley.gupta @ 8 Mar 2010 01:36 AM

@Shubhank

Please visit

http://www.codechef.com/wiki/sample-solutions#Java

i did that.. still am not

shubhank @ 8 Mar 2010 01:47 AM

i did that.. still am not able to submit.

@Shubank please use only

nirley.gupta @ 8 Mar 2010 01:54 AM

@Shubank

please use only class main

@nirley.. Tried dat as well..

shubhank @ 8 Mar 2010 02:01 AM

@nirley..

Tried dat as well.. still not working..

Check all your header

nirley.gupta @ 8 Mar 2010 02:10 AM

Check all your header files.........if someone is missing

well.. it is getting compiled

shubhank @ 8 Mar 2010 02:12 AM

well.. it is getting compiled in my laptop.. so i dunt think der's ne problem wid d code..

which compiler r u

nirley.gupta @ 8 Mar 2010 02:13 AM

which compiler r u using??.....

JDK 6.. bt JDK 5 will also

shubhank @ 8 Mar 2010 02:20 AM

JDK 6.. bt JDK 5 will also compile it without any error i guess.. not much difference is their amongst the 2 unless u r using GUI which i am not..

mail ur code

nirley.gupta @ 8 Mar 2010 02:25 AM

mail ur code to algothika.algochallenge@gmail.com and we will get back to u........

i did dat.. abt an hour ago..

shubhank @ 8 Mar 2010 02:28 AM

i did dat.. abt an hour ago..

my program is working for all

khyatigupta @ 8 Mar 2010 07:09 PM

my program is working for all the test cases and for big nos also

bt it is saying wrong answer ..

please help me out??

@Khyati Please check your

nirley.gupta @ 8 Mar 2010 07:28 PM

@Khyati

Please check your algorithm for smalll number and large numbers...... itz not right

its working correctly for

khyatigupta @ 8 Mar 2010 08:35 PM

its working correctly for small number and large nos as well ....

i hv checked it again and again

help me.....

rply...

khyatigupta @ 9 Mar 2010 12:02 AM

rply...

@Khyati mail me ur program to

nirley.gupta @ 9 Mar 2010 12:14 AM

@Khyati

mail me ur program to  algothika.algochallenge@gmail.com

i hv sent u the

khyatigupta @ 9 Mar 2010 12:29 AM

i hv sent u the mail......thanks

tl me wat was wrong with my

khyatigupta @ 9 Mar 2010 09:42 PM

tl me wat was wrong with my code??

@Khyati As i told u earlier

nirley.gupta @ 10 Mar 2010 12:30 AM

@Khyati

As i told u earlier there is a little basic mistake in ur program

We cannot correct ur code under the rules and regulations of contest...

But still check all your loops........

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Programming Competition Fetching successful submissions
Directi Go for Gold
CodeChef is a global programming communityCodeChef hosts online programming competitions
CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of computer programming. At CodeChef we work hard to revive the geek in you by hosting programming contests on a monthly basis. We also aim to have training sessions and events related to online programming for programmers around the world. Apart from providing a platform for programming competitions, CodeChef also has various tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our judge accepts solutions in over 35+ programming languages. Online programming was never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming competitions that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly programming contests and the shorter format Cook-off programming contests. Put yourself up for recognition and win great prizes. Prizes worth up to Rs.20,000 and $700 are up for grabs every month along with lots more CodeChef goodies.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be part of CodeChefs Forums and interact with all our programmers love helping out other programmers and share their ideas.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. Be a part of the CodeChef community through CodeChef meetups and techtalks. You can also host a programming contest for your institute on CodeChef and be a guest author on our blog.

Domain Name Registration, Web hosting, and Website Design provided by BigRock.com