编程介的小学生 2017-09-13 15:43 采纳率: 20.5%
浏览 641
已采纳

Diamond Dealer

Problem Description
Mr. Chou is the atworld diamond dealer. It is important that he knows the value of his (twodimensional) diamonds in order to be a succesful businessman. Mr. Chou is tired of calculating the values by hand and you have to write a program that makes the calculation for him.

Figure 2: Example diamond

The value of a diamond is determined by smoothness of its surface. This
depends on the amount of faces on the surface, more faces means a smoother surface. If there are dents (marked red in gure 2) in the surface of the diamond, the value of the diamond decreases. Counting the number of dents in the surface (a) and the number of faces on the surface that are not in dents (b), the value of the diamond is determined by the following formula: v = -a * p + b * q. When v is negative, the diamond has no value (ie. zero value).

Input
The first line of input consists of the integer number n, the number of test cases;
Then, for each test case:
One line containing:
The cost for a dent in the surface of a diamond (0 <= p <= 100);
The value of a face in the surface of a diamond (0 <= q <= 100);
The number of vertices (3 <= n <= 30) used to describe the shape of the diamond.
n lines containing one pair of integers (-1000 <=xi,yi <= 1000) describing the surface of the diamond (x0,y0) - (x1,y1) -.....-(xn-1, yn-1) - (x0 ,y0) in clockwise order.
No combination of three vertices within one diamond will be linearly aligned.

Output
For each test case, the output contains one line with one number: the value of the diamond.

Sample Input
1
10 5 7
0 10
8 4
10 -7
6 -9
-5 -4
-5 7
-2 6

Sample Output
15

  • 写回答

1条回答

  • devmiao 2017-09-30 00:33
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100