+ 5

Argentina

I decide 'Argentina' In SoloLearn and I got this code. The fifth test doesn't work, what's the problem? https://code.sololearn.com/c9hlg6UfgJhT/?ref=app

25th Jan 2020, 3:45 PM
Alisa🌸🌸
Alisa🌸🌸 - avatar
15 Respostas
+ 14
A simple approach to find solution by the logic is 50 pesos= 1 dollor
25th Jan 2020, 4:21 PM
Jayakrishna 🇮🇳
+ 8
Well, lets say that we're using signed char's, whose range is -128 to 127. If you had a number, lets say 100, and multiplied it by 2, you'd get 200 which is too big for the type to handle. So it wraps around to -128 and starts counting from there. The final result would be -56. This is called overflow. If the reverse happened, it would be called underflow. The solution would be to use a type that has a bigger range, so that the multiplied value would be stored without causing overflow, or by changing your strategy, for example by not multiplying.
25th Jan 2020, 4:15 PM
Dennis
Dennis - avatar
+ 6
This is a challenge from this app. It's called 'Argentina'. I can't solve it to the end.
25th Jan 2020, 3:58 PM
Alisa🌸🌸
Alisa🌸🌸 - avatar
+ 4
The 5th test causes an overflow if you multiply.
25th Jan 2020, 4:08 PM
Dennis
Dennis - avatar
+ 3
It's hard to explain when you don't know English well
25th Jan 2020, 4:04 PM
Alisa🌸🌸
Alisa🌸🌸 - avatar
+ 3
Overflowing is like?
25th Jan 2020, 4:10 PM
Alisa🌸🌸
Alisa🌸🌸 - avatar
+ 3
Thank you, solved the problem through division, but what you're saying can come in handy later
25th Jan 2020, 5:54 PM
Alisa🌸🌸
Alisa🌸🌸 - avatar
+ 3
The Easiest code to solve this problem: a = int(input("")) b = int(input("")) c = int(a / 50) if c > b: print("Dollars") else: print("Pesos")
27th Jul 2020, 3:16 PM
Mehdi Rahimi Moghadam
Mehdi Rahimi Moghadam - avatar
+ 2
A regular unsigned int can only store numbers until about 2.1 billion. After that, it starts over from the bottom (-2.1 billion). This is called overflow. You can prevent (or rather alleviate) this problem by using a bigger number type, for example long long.
25th Jan 2020, 5:52 PM
HonFu
HonFu - avatar
27th Jan 2020, 8:19 AM
Comic_bits
Comic_bits - avatar
28th Feb 2020, 9:38 AM
高于鈞
高于鈞 - avatar
+ 1
For anyone who's having trouble understanding I tried to change around the code so it's an easy read peso = int(input()) USD = int(input()) rate = peso * 0.02 if rate > USD: print('Dollars') else: print('Pesos')
19th Nov 2023, 7:26 PM
Hezziac Bennett
Hezziac Bennett - avatar
0
I think there is overflow and your program doesn' t have "return 0;". Good lock
26th Jan 2020, 9:07 AM
Azad Bazallahi
Azad Bazallahi - avatar
0
Hello
27th Jan 2020, 2:25 PM
Rabah Ouaked
- 1
Remove "/" from p /=50
26th Jan 2020, 8:24 PM
حيدر الشامي
حيدر الشامي - avatar