Start:
Oct, 22, 2019 21:00:00
2019年秋季学期程序设计基础(C语言)第一次考试(补题)
End:
Oct, 30, 2019 01:00:00
Time elapsed:
172:00:00
Time remaining:
00:00:00
Time Limit: 10 s
Memory Limit: 256 MB
Submission:218
AC:57
Score:0
Description
给出一个二元函数f(x,y)=ax^2+bx+cy^2+dy+e
请求出f(x,y)在{(x,y)|-n \lt x \lt n,-m \lt y \lt m}范围内所有整点上的最小值
Input
第一行为一个整数T,代表有T组数据(0 \lt T \lt 10)
每组数据第一行为两个整数n和m(1 \lt n,m \lt 1000)
第二行五个整数a,b,c,d,e(a,b,c,d,e \lt10000)
分别对应题面中给出的含义
Output
每组数据输出一行答案
答案为函数在区间内所有整点上的最小值
Samples
input
1
100 100
1 0 1 0 0
output
0
input
2
100 100
1 -2 1 -4 -45
100 100
2 -4 1 -4 -44
output
-50
-50
Hint
对于第一组样例,最小值为f(0,0)=0
对于第二组样例,最小值均为f(1,2)=-50
建议使用long long