All Tracks Algorithms Searching Linear Search Problem

Golden rectangles
Tag(s):

Algorithms, Easy, Linear Search, Searching

Problem
Editorial
Analytics

You have \(N\) rectangles. A rectangle is golden if the ratio of its sides is in between \([1.6, 1.7]\), both inclusive. Your task is to find the number of golden rectangles.

Input format

  • First line: Integer \(N\) denoting the number of rectangles
  • Each of the \(N\) following lines: Two integers \(W, H\) denoting the width and height of a rectangle

Output format

  • Print the answer in a single line.

Constraints

\(1 \le N \le 10^5\)

\(1 \le W, H \le 10^9\)

SAMPLE INPUT
5
10 1
165 100
180 100
170 100
160 100

SAMPLE OUTPUT
3
Explanation

There are three golden rectangles: (165, 100), (170, 100), (160, 100).

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

HackerEarth

Challenge Name

HourStorm #5

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications

?