10490 - Mr. Azad and his Son!!!!!

All about problems in Volume 104. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

pingus
New poster
Posts: 18
Joined: Sat May 03, 2003 10:33 pm

10490 - Mr. Azad and his Son!!!!!

Post by pingus » Sun May 04, 2003 11:49 am

Why WA ?

[c] Now, I get AC[/c]

Thank you , red Scorpion
Last edited by pingus on Wed Aug 13, 2003 4:17 pm, edited 1 time in total.

Red Scorpion
Experienced poster
Posts: 192
Joined: Sat Nov 30, 2002 5:14 am

Post by Red Scorpion » Mon May 05, 2003 11:33 am

Hi! Pingus.

I think your code is right.
I don't find anything wrong with your code!
:lol:

carneiro
Learning poster
Posts: 54
Joined: Sun May 18, 2003 1:19 am
Location: Rio de Janeiro, Brazil
Contact:

Post by carneiro » Sat May 24, 2003 12:27 pm

m should be :

unsigned long long int m;

as the problem says, it could be a 64 bit integer. long long int is 63 bit.

just change that and it should be accepted.
[]s
Mauricio Oliveira Carneiro

Red Scorpion
Experienced poster
Posts: 192
Joined: Sat Nov 30, 2002 5:14 am

Post by Red Scorpion » Mon May 26, 2003 4:43 am

m should be :
unsigned long long int m;
Hi,
I got AC when using long long, so I think that's not the problem.

:lol: :lol: :lol: :lol:

Noim
Learning poster
Posts: 88
Joined: Sun Oct 13, 2002 6:11 am
Location: Bangladesh

Post by Noim » Sun Jun 08, 2003 11:25 am

hi pingus,

are you sure you are getting WA for this program.
i got accepted using your program without changing anything.
Submit this program with o-matic page(http://acm.uva.es/problemset/submit.php)
and then observe the result.

may be WA for your mailing problem.
__nOi.m....

Noim
Learning poster
Posts: 88
Joined: Sun Oct 13, 2002 6:11 am
Location: Bangladesh

Post by Noim » Sat Jun 14, 2003 6:27 pm

hi vega.marcin,

The output of your program is wrong when the input is 31.
__nOi.m....

sumankar
A great helper
Posts: 286
Joined: Tue Mar 25, 2003 8:36 am
Location: calcutta
Contact:

10490:Mr Azad

Post by sumankar » Fri Nov 28, 2003 9:30 am

This is going to be a spoiler !
except for 11 23 and 29 i am calculating the rest
using the formula .
am i wrong ??

please help :oops: :oops:

User avatar
shamim
A great helper
Posts: 498
Joined: Mon Dec 30, 2002 10:10 am
Location: Bozeman, Montana, USA

Post by shamim » Sat Nov 29, 2003 5:56 am

there is a property associated with the formula which you can use to test all 31 cases, wiht no exceptions. :wink:

User avatar
babor
New poster
Posts: 16
Joined: Sat Jun 07, 2003 4:23 pm
Contact:

Post by babor » Thu Jan 22, 2004 1:31 pm

Hai there is a very well known formula in "number theory ".

if p is a prime & 2^p -1 is a prime then (2^p-1)*(2^p -1 ) is a
perfect number . And this is the solution.
Thanks
babor

WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

10490

Post by WR » Thu Mar 04, 2004 10:31 am

Hi, could somebody please explain problem 10490 to me?!

The OJ returns WA!

As I understood the problem the output is as follows
("n: " added for clarity)

2: Perfect: 6!
3: Perfect: 28!
5: Perfect: 496!
7: Perfect: 8128!
13: Perfect: 33550336!
17: Perfect: 8589869056!
19: Perfect: 137438691328!
31: Perfect: 2305843008139952128!

For any other input n (2 <= n <= 31) a perfect number does not exist!

Output is then either

"Given number is NOT prime! NO perfect number is available."

or

"Given number is prime. But, NO perfect number is available."

One can compute a perfect number from 2^(n-1) * (2^n - 1)
if (2^n - 1) is prime and n is prime (proof by Euclid, as far
as I know).

Well that equation holds for EVEN perfect numbers, but I don't really think
that's my problem (just a joke).

Probably one of my usual silly mistakes but where?

osan
New poster
Posts: 47
Joined: Tue Jul 29, 2003 12:03 pm
Location: Bangladesh,Dhaka.
Contact:

the problemsetter is sucks

Post by osan » Tue Mar 09, 2004 7:55 pm

in this problem u can get AC in short time by handle 6 perfect number as special case && primes less than 32.
:))
this time WA
what next...............?

WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

Post by WR » Thu Mar 11, 2004 1:15 pm

Thanks for the post Osan,

but the riddle remains.

1) If the formula from my original post is correct, then only
primes generate perfect numbers.

2) Considering the primes up to 31, 11, 23 and 29 are primes
that do not generate a perfect number.

So the output for all integers between 2 and 31 should be

Code: Select all

Perfect: 6!
Perfect: 28!
Given number is NOT prime! NO perfect number is available.
Perfect: 496!
Given number is NOT prime! NO perfect number is available.
Perfect: 8128!
Given number is NOT prime! NO perfect number is available.
Given number is NOT prime! NO perfect number is available.
Given number is NOT prime! NO perfect number is available.
Given number is prime. But, NO perfect number is available.
Given number is NOT prime! NO perfect number is available.
Perfect: 33550336!
Given number is NOT prime! NO perfect number is available.
Given number is NOT prime! NO perfect number is available.
Given number is NOT prime! NO perfect number is available.
Perfect: 8589869056!
Given number is NOT prime! NO perfect number is available.
Perfect: 137438691328!
Given number is NOT prime! NO perfect number is available.
Given number is NOT prime! NO perfect number is available.
Given number is NOT prime! NO perfect number is available.
Given number is prime. But, NO perfect number is available.
Given number is NOT prime! NO perfect number is available.
Given number is NOT prime! NO perfect number is available.
Given number is NOT prime! NO perfect number is available.
Given number is NOT prime! NO perfect number is available.
Given number is NOT prime! NO perfect number is available.
Given number is prime. But, NO perfect number is available.
Given number is NOT prime! NO perfect number is available.
Perfect: 2305843008139952128!
In my opinion that should be ok and the answer to the problem.

What do you mean by 6 perfect numbers as special cases?

User avatar
Sedefcho
A great helper
Posts: 374
Joined: Sun Jan 16, 2005 10:18 pm
Location: Bulgaria

Post by Sedefcho » Mon Mar 14, 2005 7:04 pm


Hi, WR !

Your output seems OK to me.
Compare it once again with my output ( the output
from an ACC program ).


Just one question - what is your output for N=1 ?
I know they say N>1 but I handle the case N=1 too.


The output below is for an input file containing 32 lines.
On the first 31 lines I have the consequent numbers 1,2,3...,31.
On the 32nd line I have the number 0.

Code: Select all

Given number is NOT prime! NO perfect number is available.
Perfect: 6!
Perfect: 28!
Given number is NOT prime! NO perfect number is available.
Perfect: 496!
Given number is NOT prime! NO perfect number is available.
Perfect: 8128!
Given number is NOT prime! NO perfect number is available.
Given number is NOT prime! NO perfect number is available.
Given number is NOT prime! NO perfect number is available.
Given number is prime. But, NO perfect number is available.
Given number is NOT prime! NO perfect number is available.
Perfect: 33550336!
Given number is NOT prime! NO perfect number is available.
Given number is NOT prime! NO perfect number is available.
Given number is NOT prime! NO perfect number is available.
Perfect: 8589869056!
Given number is NOT prime! NO perfect number is available.
Perfect: 137438691328!
Given number is NOT prime! NO perfect number is available.
Given number is NOT prime! NO perfect number is available.
Given number is NOT prime! NO perfect number is available.
Given number is prime. But, NO perfect number is available.
Given number is NOT prime! NO perfect number is available.
Given number is NOT prime! NO perfect number is available.
Given number is NOT prime! NO perfect number is available.
Given number is NOT prime! NO perfect number is available.
Given number is NOT prime! NO perfect number is available.
Given number is prime. But, NO perfect number is available.
Given number is NOT prime! NO perfect number is available.
Perfect: 2305843008139952128!

WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

Post by WR » Tue Mar 15, 2005 8:45 am

Thanks for the reply.

I've solved this problem half a year ago but forgot to post that.

Nevertheless, thanks for the attention.

User avatar
Rocky
Experienced poster
Posts: 124
Joined: Thu Oct 14, 2004 9:05 am
Contact:

Good Help

Post by Rocky » Sun Mar 20, 2005 12:23 pm

Yeh Sedefcho
You Are Right I do the Same & Got ACC..
Thanks. :lol:

Post Reply

Return to “Volume 104 (10400-10499)”