This page is still under construction.

Parts of this page are still being built. What you see may change.

Heptathlon

Time limit1sMemory limit128 MB

Summary
The program converts seven event records into scores with the given formulas and prints the total for each test case.
Level

Easy1 of 10

Topics
Implementation, Math
Solved
No attempts yet

Problem

Minhyeok is competing in a heptathlon. The heptathlon combines the following seven track and field events: the 100 metre hurdles, high jump, shot put, 200 metre dash, long jump, javelin throw, and 800 metre run. Given Minhyeok's record in each event, write a program that converts every record into a score and reports the total.

The total is the sum of the seven event scores. Each event score is computed with the formula below, where ⌊x⌋\lfloor x \rfloor is the greatest integer not exceeding xx (the floor).

  • Track events: Score=⌊A×(B−P)C⌋\text{Score} = \lfloor A \times (B - P)^{C} \rfloor
  • Field events: Score=⌊A×(P−B)C⌋\text{Score} = \lfloor A \times (P - B)^{C} \rfloor

AA, BB, and CC are constants fixed for each event, and PP is the athlete's record. The constants and the unit of PP for each event are listed below.

EventAABBCCUnit of PPType
100 m hurdles9.2307626.71.835secTrack
High jump1.84523751.348cmField
Shot put56.02111.51.05mField
200 m dash4.9908742.51.81secTrack
Long jump0.1888072101.41cmField
Javelin throw15.98033.81.04mField
800 m run0.111932541.88secTrack

Every event score is an integer. Moreover, every field event satisfies B≤PB \le P, and every track event satisfies P≤BP \le B.

Input

The first line contains the number of test cases TT (1≤T≤10001 \le T \le 1000).

Each test case is one line of seven integers, Minhyeok's records for the events in this order: 100 m hurdles, high jump, shot put, 200 m dash, long jump, javelin throw, 800 m run.

Output

For each test case, print Minhyeok's total score on its own line.

Examples1

  1. Example 1

    Input
    3
    19 90 11 29 264 20 131
    12 95 21 37 224 35 221
    17 168 15 23 275 22 241
    
    Expected output
    2901
    3419
    3772