11371 - Number Theory for Newbies

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

Moderator: Board moderators

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: Got WA at UVa 11371 - Number Theory for Newbies

Post by brianfry713 »

brianfry713 wrote:Input 191, correct output:911 - 119 = 792 = 9 * 88
Each line of input gives a positive integer n (? 2000000000). You are to find two integers a and b formed by rearranging the digits of n, such that a-b is maximum.

In my AC output a - b = 792, with is greater than 720 in your WA output.
Check input and AC output for thousands of problems on uDebug!
Rika71
New poster
Posts: 11
Joined: Sat Apr 26, 2014 9:42 pm

Re: 11371 - Number Theory for Newbies

Post by Rika71 »

getting WA.please help.thank you

Code: Select all

removed after AC
Last edited by Rika71 on Sun May 04, 2014 3:59 pm, edited 1 time in total.
lbv
Experienced poster
Posts: 128
Joined: Tue Nov 29, 2011 8:40 am

Re: 11371 - Number Theory for Newbies

Post by lbv »

Rika71 wrote:getting WA.please help.thank you
That looks like AC code. However, if you submitted your code as ANSI C, note that the atoll function will not be available.

If you have access to a gcc compiler, try compiling your programs using the same flags used by the UVa server, which for ANSI C are: "-lm -lcrypt -O2 -pipe -ansi -DONLINE_JUDGE", and that'll help you catch this type of bugs.
Rika71
New poster
Posts: 11
Joined: Sat Apr 26, 2014 9:42 pm

Re: 11371 - Number Theory for Newbies

Post by Rika71 »

That looks like AC code. However, if you submitted your code as ANSI C, note that the atoll function will not be available.
Thank you so much lbv.I didnt know atoll is not ANSI supported.Thanks for teaching me.I just manually built that function & got AC.Thanks again!!! :D
mobarak.islam
New poster
Posts: 38
Joined: Wed Dec 05, 2012 11:29 pm

Re: 11371 - Number Theory for Newbies

Post by mobarak.islam »

I am getting WA here. Though all the I/O given in problem and this discussion board have given correct answer.

Code: Select all

Removed after getting AC :)
Last edited by mobarak.islam on Tue Dec 30, 2014 6:56 am, edited 1 time in total.
lighted
Guru
Posts: 587
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 11371 - Number Theory for Newbies

Post by lighted »

This line can give undefined results when you try to access value of a because your array is a[10].

Code: Select all

for (int i = 1; i <= 10; i++)
Change line to

Code: Select all

for (int i = 1; i < 10; i++)
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
Post Reply

Return to “Volume 113 (11300-11399)”