Codeforces Round #478 (Div. 2) d-ghosts

Source: Internet
Author: User
Tags time limit
D. Ghosts time limit per test 2 seconds memory limit per test megabytes input standard input output standard output

Ghosts live in harmony and peace, they travel the space without any purpose other than scare whoever stands in their.

There is nn ghosts in the universe, they move in the oxyoxy plane, each one of the them have its own velocity that does not ch Ange in Time:→v=vx→i+vy→jv→=vxi→+vyj→where VXVX is the IT speed on the Xx-axis and Vyvy are on the Yy-axis.

A Ghost II has experience value Exiexi, which represent how many ghosts tried to scare him in his past. The ghosts scare each and the other if they were in the same Cartesian point at a moment of time.

As the ghosts move with constant speed, after some moment of time there'll be no further scaring (what a relief!) and th E Experience of Ghost kind Gx=∑ni=1exigx=∑i=1nexi would never increase.

Tameem is a red giant, he took a picture of the Cartesian plane at a certain moment of time TT, and magically all the Ghos TS were aligned on a line of the form y=a⋅x+by=a⋅x+b. You had to compute what would be the experience index of the ghost kind gxgx in the indefinite future and this is your task F or today.

Note if Tameem took the picture, GXGX could already be greater than XX, because many ghosts may have scared one anoth Er at any moment between [−∞,t][−∞,t]. Input

The first line contains three integers nn, aa and BB (1≤n≤2000001≤n≤200000, 1≤|a|≤1091≤|a|≤109, 0≤|b

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.