EaglePB2's Competitive Programming Writeups
  • Home Page
  • Why Python?
  • Why 10^9 + 7?
  • General Formatting Title
  • πŸ‡²πŸ‡ΎCodeNection
    • 2021
      • Closed Cateogry
        • Attend Talks
        • Distant Relatives
        • Concert
        • Mamak
        • Fair Contest
      • Open Preliminary Round
        • f(Aibohphobia)^-1
        • Did they cheat?
        • Semester Breaks
      • Open Final Round
        • Ways 1
        • Circular Campus
        • A joke
        • πŸ₯°Last year when life was better
        • Thank You Pizza
    • 2023
      • Test Round
        • Codey and Alphabetical Scoring
        • Codey and Binary Guesser
      • Preliminary Round
        • Codey and CodeNection
        • Codey and Hide-and-Seek
        • Codey and Math
        • Codey and Textbooks
        • Codey and Money
        • Codey and Team Selection
        • Codey and Painted Tree
        • Codey and Number Grid
        • Codey and Crimes
      • Final Round
        • Codey and CodeNection 2
        • Codey and Connection
        • Codey and Schedule
        • Codey and School Supplies
        • Codey and Zombies
        • Codey and Sightseeing
        • Codey and Apples
        • Codey and Facto
        • Codey and Zoey
    • 2024
      • Test Round
        • Codey and Sunday
        • Codey and Takoyaki
      • Preliminary Round
        • Codey and CodeNection
        • Codey and Pebbles
        • Codey and Spam
        • Codey and Coins
        • Codey and Rectangles
        • Codey and Manuscript
        • Codey and Recipes
        • Codey and Toy Kingdom
        • Codey and Peaks
      • Final Round
        • Codey and Exit
        • Codey and Gardening
        • Codey and Symbol
        • Codey and Rectangles 2
        • Codey and Jutsu
        • Codey and Toy Kingdom 2
        • Codey and Speeches
  • ABaKoDa
    • 2023
      • Round 1
        • Problem Letters
        • Problem Statistics
        • Rankings Order
        • Rankings Search
      • Round 2
        • Abakoda Letters
        • Borrowed Words
        • Kensorship
        • Duel Languages
  • Meta Coding Competitions
    • 2011
      • Qualification Round
        • Double Squares
        • Peg Game
        • Studious Student
      • Round 1A
        • Diversity Number
        • Turn on the Lights
        • Wine Tasting
      • Round 1B
        • Chess 2
        • Diminishing Circle
        • Slot Machine Hacker
      • Round 1C
        • N-Factorful
        • Polynomial Factoring
        • Risky Slide
      • Round 2
        • Bonus Assignments
        • Scott's New Trick
        • Studious Student II
      • Final Round
        • Alien Game
        • Party Time
        • Safest Place
  • EaglePB2's Special
    • Hong Kong Identity card
    • Cycle Prefix Averages
    • Word Squares
Powered by GitBook
On this page
  • Question
  • Input Format
  • Constraints
  • Output Format
  • Sample Inputs:
  1. CodeNection
  2. 2024
  3. Final Round

Codey and Symbol

https://www.hackerrank.com/contests/codenection-2024-final-round-open-category/challenges/cn24-4/problem

PreviousCodey and GardeningNextCodey and Rectangles 2

Last updated 2 months ago

Question

Codey was working on an equation but accidentally spilled water on its notes, blurring one of the symbols. Now, it can’t tell the correct relationship between the two sides of its equation.

The equation is given as:

aβˆ’(bc)?(de)βˆ’fa - (\frac{b}{c}) ? (\frac{d}{e}) - faβˆ’(cb​)?(ed​)βˆ’f

Help Codey find the relationship ?.

Print > if the left side is bigger, < if the right side is bigger, otherwise =.

Input Format

The first line contains 6 values, a,b,c,d,e,fa,b,c,d,e,fa,b,c,d,e,f.

Constraints

0≀a,b,c,d,e,f≀1050 \le a, b, c, d, e, f \le 10^50≀a,b,c,d,e,f≀105

Output Format

Print a single character:

Sample Inputs:

Input

5 6 2 8 4 1

Output

>

Explanation


Solution - Rounding Trap

This question is more like testing if you know programming rounding issues.

In some reason, when you divide a value, the number would get different when it rounds too many significant values, which is in default. (which we called, float rounding error)

Therefore, when comparing, don't forget to round to 4 values or fewer, so that the comparison will be correct.

Here's the code:

a, b, c, d, e, f = map(int, input().strip().split())
lhs = a - (b / c)
rhs = (d / e) - f

if round(lhs, 4) > round(rhs, 4):
    print(">")
elif round(rhs, 4) > round(lhs, 4):
    print("<")
else:
    print("=")
c,e≠0c, e \ne 0c,e=0

>>>, if left side is larger.

<<<, if left side is smaller.

===, if both sides are equal.

Left Side: 5βˆ’(62)=25 - (\frac{6}{2}) = 25βˆ’(26​)=2

Right Side: (84)βˆ’1=1(\frac{8}{4}) - 1 = 1(48​)βˆ’1=1

2>12>12>1, therefore output >.

πŸ‡²πŸ‡Ύ