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
    • February CookOff
    • February Long Contest
    • January CookOff
  • DISCUSS
    • Wiki
    • Forums
    • Blog
    • 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
    • Ranks
    • Tutorials
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Compete » Codechef Campus Snackdown » Rational Numbers

Rational Numbers

Problem code: SNCK04

  • All Submissions

All submissions for this problem are available.

A positive rational number is a real number which can be expressed as P/Q where P, Q are coprime positive intergers. The Chef is very hungry and can get food only if he solves the following question. "Given a number N, find the number of positive rational numbers less than 1 such that when expressed as P/Q, both P, Q are less than or equal to N". Please help the Chef in answering this question. The Chef promises to share the food with you.


Input

The first line contain a single integer T, the number of test cases. Following T (<= 1000) lines will contain a test case, a single number N (<= 1000000).


Output

For each test case print the output on a single line.


Example

Input:
3
1
2
3

Output:
0
1
3

Date: 2009-11-16
Time limit: 3s
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.

why i cannot submit?

Mushroom @ 21 Nov 2009 07:36 PM

why i cannot submit?

are we allowed to use

Carpenters @ 21 Nov 2009 07:38 PM

are we allowed to use threading to speed up our programs

How to submit ?  

sivaraman @ 21 Nov 2009 07:46 PM

How to submit ?

 

i am getting error restricted

sai4anand @ 21 Nov 2009 07:48 PM

i am getting error restricted content while submitting..help|????

You should log in from your

admin @ 21 Nov 2009 07:51 PM

You should log in from your team accounts in order to submit a problem.

You are not allowed to use

admin @ 21 Nov 2009 07:51 PM

You are not allowed to use threads.

"restricted content" ?? how

rmstar @ 21 Nov 2009 08:02 PM

"restricted content" ?? how to submit ??

hey i forgot my team

sai4anand @ 21 Nov 2009 08:08 PM

hey i forgot my team name...what to do??

We are logged in our team

cv @ 21 Nov 2009 08:13 PM

We are logged in our team account.. But still "restricted content" coming..

why i cannot submit the

Balajipr @ 21 Nov 2009 08:14 PM

why i cannot submit the solutions...?

We are logged in our team

Balajipr @ 21 Nov 2009 08:15 PM

We are logged in our team account.. But still "restricted content" coming..

You need to log in from your

admin @ 21 Nov 2009 08:16 PM

You need to log in from your team accounts in order to submit a solution.

How to login 4m team's

sumitb @ 21 Nov 2009 08:17 PM

How to login 4m team's account
it is not accepting team name and password
Team name Bytecoders

@Sumit You have to log in

admin @ 21 Nov 2009 08:22 PM

@Sumit

You have to log in from your team name and password. The only reason it may not accept is if you are entering one of them incorrectly.

i have been trying for around

gautamverma @ 21 Nov 2009 08:27 PM

i have been trying for around 1 hr and not able to login.

My team name is coder can admin help me out?

can you mail me my password? please help me out?

hey. are the input numbers

iitkgp @ 21 Nov 2009 08:31 PM

hey. are the input numbers sorted????

@KGP-rockers Each test case

admin @ 21 Nov 2009 08:33 PM

@KGP-rockers

Each test case contains only a single number N. The test cases may not be in sorted order.

 

We are logged in from our

cv @ 21 Nov 2009 08:36 PM

We are logged in from our team account which is 'cv' but still we are no able to submit. A message "Restricted Content" is coming each time we click Submit.

hey. are the input numbers

iitkgp @ 21 Nov 2009 08:38 PM

hey. are the input numbers sorted????

@ chandra villa You have not

admin @ 21 Nov 2009 08:42 PM

@ chandra villa

You have not registered for Snackdown. Your team is registered for the test contest. You need to register separately for this.

@aniruddha any chance for us

cv @ 21 Nov 2009 08:46 PM

@aniruddha any chance for us competing now??

we were not aware that we had to register separately for today's event

plzzzzzz

@ chandra villa You cannot

admin @ 21 Nov 2009 08:50 PM

@ chandra villa

You cannot participate in today's contest. There are going to be other team contest in the future, you can participate then.

"restricted content" ??

Gladiator @ 21 Nov 2009 09:11 PM

"restricted content" ?? unable to submit.

How to submit ??

"restricted content" ??

Gladiator @ 21 Nov 2009 09:11 PM

"restricted content" ?? unable to submit.

How to submit ??

Busted again

busted @ 21 Nov 2009 09:17 PM

Busted again muddafuckas!

 

What the fuck man! Im tellin you, lemme handle this shit, the world will be much happier.

Fuckin assholes got the braniest motherfuckers up their mama's pussy butr still cant lick their own assholes.

 

how to submit the sol..  

BCD @ 21 Nov 2009 09:20 PM

how to submit the sol..

 

Fuck the mothers of those

Gladiator @ 21 Nov 2009 09:29 PM

Fuck the mothers of those chefs who found out such an unorganised layout for such a contest which seems to be great but is rather fucking.

@chayya you have to log in

admin @ 21 Nov 2009 09:30 PM

@chayya you have to log in from your team id

what is the lower bound for

iiitdmCoder @ 21 Nov 2009 10:10 PM

what is the lower bound for N?

i am also not able to submit

nnnn @ 21 Nov 2009 10:11 PM

i am also not able to submit the content "RESTRICTRD CONTENT" aDMINS PLEASE HELP...i am logged in from my team account

@ Nalin You were supposed to

admin @ 21 Nov 2009 10:15 PM

@ Nalin

You were supposed to register separately for snackdown. You probably registered for the test contest.

@Aniruddha my code is as

TheCoderzz @ 21 Nov 2009 10:17 PM

@Aniruddha my code is as clean as it gets but its in Java which makes it slower.... cnt u allow for a slightly longer running time if we code in Java ?

@Aniruddha.. i forgot my team

kartikaneja @ 21 Nov 2009 10:20 PM

@Aniruddha.. i forgot my team password (team name is TAANSTAFL or T.A.A.N.S.T.A.F.L.).. can you please confirm if we are registered for snackdown or not?

@ Kartik If you are not able

admin @ 21 Nov 2009 10:24 PM

@ Kartik

If you are not able to log in then you are not registered for the contest.

@Aniruddha.....what do u

nnnn @ 21 Nov 2009 10:24 PM

@Aniruddha.....what do u mean......i registered through the link in my mail....

wasnt the link for SNACKDOWN..........????

@ Nalin If you registered

admin @ 21 Nov 2009 10:28 PM

@ Nalin

If you registered through that link then you should be able to log in using your team name and password. Since this is a team contest and more than one user uses the same team account we dont allow changing the team password.

@Aniruddha.....what do u

nnnn @ 21 Nov 2009 10:29 PM

@Aniruddha.....what do u mean......i registered through the link in my mail....

wasnt the link for SNACKDOWN..........????

@Aniruddha.. honestly.. i

kartikaneja @ 21 Nov 2009 10:29 PM

@Aniruddha.. honestly.. i forgot my team name.. is there any way of finding out my team the team name i am registered under. My team members include "Nitant" and "alphaq"

so can u pls tell me my team

nnnn @ 21 Nov 2009 10:30 PM

so can u pls tell me my team name.......i have forgotten....if it is "nnnn" or "nnnn1".........!!!

pls mail my team name at my

nnnn @ 21 Nov 2009 10:32 PM

pls mail my team name at my email........

and if it is "nnnn" then I am

nnnn @ 21 Nov 2009 10:33 PM

and if it is "nnnn" then I am logged in with my team name already.......

for input number of 1000000,

arit.mondal @ 21 Nov 2009 10:38 PM

for input number of 1000000, we are getting high runtime...so what can be the maximum possible number allowed in the input?in the testcase will there be any number as large as 1000000?

HEY ADMIN....... my code is

nnnn1 @ 21 Nov 2009 10:39 PM

HEY ADMIN.......

my code is in JAVA and is showing following error.....

spoj: The program compiled successfully, but Main.class was not found. Class Main should contain method: public static void main (String[] args).

 

but i have a main method....am i supposed to submit my code using "Netbeans"...

pls help.......

@ Nalin You had to register

admin @ 21 Nov 2009 10:40 PM

@ Nalin

You had to register separately for snackdown. If you are already logged in with some team name you need to make sure that it is the same as the one registered for snackdown. If you are not able to submit a solution then you are not logged in with the team name you registered for this contest. We dont allow retrieving user names and passwords.

@ Arit There can be an input

admin @ 21 Nov 2009 10:44 PM

@ Arit

There can be an input with n = 1000000. But not more than that.

HEY ADMIN....... my code is

nnnn1 @ 21 Nov 2009 10:53 PM

HEY ADMIN.......

my code is in JAVA and is showing following error.....

spoj: The program compiled successfully, but Main.class was not found. Class Main should contain method: public static void main (String[] args).

 

but i have a main method....am i supposed to submit my code using "Netbeans"...else my program is running correctly....

pls help.......

@Aniruddha.. is there no way

kartikaneja @ 21 Nov 2009 10:53 PM

@Aniruddha.. is there no way of finding out my team name.. i've already solved two questions.. please email me at my account's email address if privacy is an issue.

Hey can anybody tell me the

Byters @ 21 Nov 2009 10:57 PM

Hey can anybody tell me the trick how to get the code working for n=1000000, it is taking too long.
My code is working fine for smaller inputs

plz help me out.....anybody

yaar time complexity ki

AGAR @ 21 Nov 2009 11:05 PM

yaar time complexity ki problem aa rahi hai kuch to help karo :(

my program when submitted

xploiter @ 21 Nov 2009 11:19 PM

my program when submitted shows running only for more than 2 minutes

WTH? Couldnt Submit. Same

rjdthegreat @ 22 Nov 2009 12:08 AM

WTH?

Couldnt Submit. Same Restricted Content Crap.

Worked my brain off on this one. Solved it and Couldn't submit in the end.

Not happy with the event.

ReEvent.

 

where is the link for

bitsgrox @ 22 Nov 2009 04:32 PM

where is the link for submission??

I m unale to find the link

Sangharsh @ 22 Nov 2009 07:01 PM

I m unale to find the link for sublmission of soutions

HOW come tnu2 bcome eligible

akshay9235 @ 23 Nov 2009 01:48 PM

HOW come tnu2 bcome eligible for MUMBAI finals..   isn't the contest for students of indian universities..  eh?

when will these problems be

rajatag12 @ 24 Nov 2009 06:50 PM

when will these problems be shifted to practice section ?

The problems are now in the

admin @ 24 Nov 2009 07:47 PM

The problems are now in the practice section.

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