All about problems in Volume 106. If there is a thread about your problem, please use it. If not, create one with its number in the subject.
Moderator: Board moderators
windows2k
Experienced poster
Posts: 136 Joined: Sat Apr 05, 2003 3:29 pm
Location: Taiwan
Post
by windows2k » Fri Apr 09, 2004 10:36 am
I thought it is an easy problem.
But get WA all the time.
What's wrong with my input/output
input
output
Or someone could give some tricky input/output, thx
rotoZOOM
Learning poster
Posts: 63 Joined: Mon Dec 22, 2003 5:05 am
Location: Russia, Chelyabinsk
Contact:
Post
by rotoZOOM » Fri Apr 09, 2004 12:12 pm
Check trailing spaces in output.
You should use unsigned long long instead of signed long long.
Input:
1000000000000000000
Output:
1111111111111111111
prince56k
New poster
Posts: 33 Joined: Fri Dec 12, 2003 10:32 pm
Location: BANGLADESH
Post
by prince56k » Fri Apr 09, 2004 1:25 pm
i don't think that u should use unsigned long long. i used only long long.
if n=9 output 10
and if u use 10*n/9 then u will face overflow problem if n is 18 digit
Hope, it will help u
Eduard
Experienced poster
Posts: 183 Joined: Fri Sep 26, 2003 2:54 pm
Location: Armenia,Yerevan
Post
by Eduard » Fri Apr 09, 2004 2:14 pm
Maybe 10^18 is not so big,but i use big numbers and got AC at one's.
I don't know how in C++ may be long long is bigger than 10^18 but in Pascal i don't think that INT64 is bigger than 10^18.That why i use big numbers.
PdR
New poster
Posts: 24 Joined: Mon Dec 30, 2002 4:27 am
Post
by PdR » Fri Apr 09, 2004 3:36 pm
With some care no overflow will ever ocur in a 64 bit signed integer.
mlvahe
New poster
Posts: 23 Joined: Wed Jul 30, 2003 6:54 am
Location: Yerevan, Armenia
Post
by mlvahe » Sun Apr 11, 2004 12:39 pm
In Pascal INT64 type can store integers, less than 2^63-1>10^18. So you could fill free to use int64.
10*a/9 = a + a/9.
if you write this way you won't meet any overflowing.
P.S. This is realy very easy problem.
Sajid
Learning poster
Posts: 94 Joined: Sat Oct 05, 2002 5:34 pm
Location: CS - AIUB, Dhaka, Bangladesh.
Contact:
Post
by Sajid » Fri Apr 16, 2004 9:38 pm
How can we detemine about the multiple answer...?
(we can find out a number easily by the formula)
shamim
A great helper
Posts: 498 Joined: Mon Dec 30, 2002 10:10 am
Location: Bozeman, Montana, USA
Post
by shamim » Sat Apr 17, 2004 11:58 am
The other answers lie (+-) 10 of the number calculated using formula.
Sajid
Learning poster
Posts: 94 Joined: Sat Oct 05, 2002 5:34 pm
Location: CS - AIUB, Dhaka, Bangladesh.
Contact:
Post
by Sajid » Sat Apr 17, 2004 8:12 pm
hmm, I guess, I did simple mistake in the contest. I checked only previous ten number of the calculated number....
anyway, got AC now
Larry
Guru
Posts: 647 Joined: Wed Jun 26, 2002 10:12 pm
Location: Hong Kong and New York City
Contact:
Post
by Larry » Sat Apr 17, 2004 8:20 pm
Actually, there's an easier way to check if a number is capable of multiple numbers..
Sajid
Learning poster
Posts: 94 Joined: Sat Oct 05, 2002 5:34 pm
Location: CS - AIUB, Dhaka, Bangladesh.
Contact:
Post
by Sajid » Sat Apr 17, 2004 8:39 pm
Larry,
Can you explain the ways?
Larry
Guru
Posts: 647 Joined: Wed Jun 26, 2002 10:12 pm
Location: Hong Kong and New York City
Contact:
Post
by Larry » Sun Apr 18, 2004 2:22 am
I'm not a good math prover, but either prove to yourself or believe that the most number of ways is 2.
Knowing this, most numbers will have only one solution. Try to find that special case where there are two.
Hope it helps without giving too much away.. =)
soyoja
Experienced poster
Posts: 106 Joined: Sun Feb 17, 2002 2:00 am
Location: Seoul, South Korea
Contact:
Post
by soyoja » Tue May 04, 2004 10:09 am
Just I'm so curious that why maximum answers are only two.
Of course, I think it's very natural, but I want to know the reason.
Last edited by
soyoja on Tue May 04, 2004 10:12 am, edited 2 times in total.
soyoja
Experienced poster
Posts: 106 Joined: Sun Feb 17, 2002 2:00 am
Location: Seoul, South Korea
Contact:
Post
by soyoja » Tue May 04, 2004 10:10 am
Here is general idea of this problem ^^
A = original number
B = Sample input
A - A/10 = B ( by problem description )
therefore , (10A - A)/10 = B, 9A = 10B, A = 10/9 * B
So we can find one answer.
And minus value is always made by ( A/10 ),
so another answer's range is - 10 ~ + 10 at original answer.
You can find that number by small range searching.
Larry
Guru
Posts: 647 Joined: Wed Jun 26, 2002 10:12 pm
Location: Hong Kong and New York City
Contact:
Post
by Larry » Tue May 04, 2004 11:17 pm
soyoja:
sorry, as I said, I'm not a good math prover, and it was just an intuition (that worked), so I don't know why this is the case.