Rank 161 the next year: the four-year course has three exams! Last year's rank one: Ah!…
- User
Rank 161 the next year: the four-year course has three exams!
Last year's rank one: Ah! Ah! So let 160 be your rank!
Like you, we did not understand how long this dialogue was for! But it is probably made by the designer's sick mind and has no reliable source! So that this problem does not happen again! We want to rewrite the sentences we have heard and are sure to be true!!!
For this tabular purpose n x m n×m is embedded. in line x x and column y y equal to y max ( a + x x b , c + y x d ) We write the sentence max(a+x×b,c+y×d). Now we want the total number of sentences from you.
In fact, for all columns, an arithmetic sequence with the magnitude of the ratio b b and the initial value of a a and for all rows an arithmetic sequence with the magnitude of the ratio d d and the initial value c We considered c and in each house we write sentences with the maximum number of these two numbers. You have to measure the answer which is the total number of words 1 0 9 + 7 10 9 Print +7.
input In the only input line in order of numbers n n, m M a a b b, c c and d d have come
1 ≤ n , m ≤ 1
000
000
000 1≤n,m≤1 000 000 000
0 ≤ a , b , c , d ≤ 1
000
000 0≤a,b,c,d≤1 000 000
output Print a number as the answer to the problem in the only output line.
Example Sample entry 1 3 3 0 1 0 2 Plain text Sample output 1 21 Plain text Explanation of the first example:
Pairs are:
(0,0) (0,2) (0,4) (1,0) (1,2) (1,4) (2,0) (2,2) (2,4) Plain text that the sum of the maxima of each pair is equal to 21.
Sample input 2 75164 100 97702 84646 95867 454 Plain text Sample output 2 997345518
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.