Electric Fence | ||||||
|
||||||
Description | ||||||
In this problem, ‘lattice points’ in the plane are points with integer coordinates. In order to contain his cows, Farmer John constructs a triangular electric fence by stringing a ‘hot’ wire from the origin (0,0) to a lattice point [n, m] (0<=;n<32000, 0<m<32000), then to a lattice point on the positive x axis [p,0] (p>0), and then back to the origin (0,0). A cow can be placed at each lattice point within the fence without touching the fence (very thin cows). Cows can not be placed on lattice points that the fence touches. How many cows can a given fence hold? |
||||||
Input | ||||||
First line contains an integer n: the number of test case. Then n lines follow, each line contains three space-separated integers that denote n, m, and p. |
||||||
Output | ||||||
A single line with a single integer for each test case that represents the number of cows the specified fence can hold. |
||||||
Sample Input | ||||||
2 7 5 10 1 1 2 |
||||||
Sample Output | ||||||
20 0 这题我会了皮克定理才会的,不会之前一点思路没有
一张方格纸上,上面画着纵横两组平行线,相邻平行线之间的距离都相等,这样两组平行线的交点,就是所谓格点。如果取一个格点做原点O,如图1,取通过这个格点的横向和纵向两直线分别做横坐标轴OX和纵坐标轴OY,并取原来方格边长做单位长,建立一个坐标系。这时前面所说的格点,显然就是纵横两坐标都是整数的那些点。如图1中的O、P、Q、M、N都是格点。由于这个缘故,我们又叫格点为整点。
一个多边形的顶点如果全是格点,这多边形就叫做格点多边形。有趣的是,这种格点多边形的面积计算起来很方便,只要数一下图形边线上的点的数目及图内的点的数目,就可用公式算出。 这个公式是皮克(Pick)在1899年给出的,被称为“皮克定理”,这是一个实用而有趣的定理。给定顶点坐标均是整点(或正方形格点)的简单多边形, a=39,b=14,s=45,皮克定理说明了其面积S和内部格点数目a、边上格点数目b的关系:S=a+b÷2-1。(其中a表示多边形内部的点数,b表示多边形边界上的点数,S表示多边形的面积)
|
详细解决方案
Hust oj 1056 Electric Fence(皮克定理)
热度:55 发布时间:2023-12-22 04:39:46.0
相关解决方案
- Android 闪电效果 (Electric Screen,电动荧幕)
- Educational Codeforces Round 77 C. Infinite Fence
- POJ 1037 A decorative fence DP+排列计数 *
- 1056. 组合数的和(15) PAT
- PAT甲级-1056 Mice and Rice (25分)
- PAT乙级-1056 组合数的和 (15分)
- 5-----A Short-Term Electric Load Forecasting Scheme Using 2-Stage Predictive Analytics
- 11、Electric Load Forecasting in Smart Grids Using Long-Short-Term-Memory based Recurrent Neural Netw
- 【NOIP2012模拟10.9】电费结算(electric)
- PAT - 1056. 组合数的和(15)
- [Educational Codeforces Round 75]F.Red-White Fence(OGF)
- xdoj 1056: 寻找BOSS
- (大组合数)D. Fence Building ------ ACM-ICPC 2017 Asia Urumqi
- POJ3253 Fence Repair(STL优先队列,哈夫曼树)
- POJ3253 Fence Repair(贪心,哈夫曼树)
- Fence Repair 【优先队列】
- CodeForces 234F Fence (DP)
- Educational Codeforces Round 61 (Rated for Div. 2) C. Painting the Fence(思维+暴力枚举+前缀和)
- POJ 3253 Fence Repair(哈夫曼树+优先队列)
- Fence Repair (优先队列)
- Fence Repair(优先队列)
- Vanya and Fence
- POJ - 1821 Fence(单调队列优化DP)
- POJ - 3253 Fence Repair(优先队列)
- ZZULIOJ 1056: 幸运数字,Java
- 洛谷 P1090 合并果子 / [USACO06NOV] Fence Repair G
- P1090 [NOIP2004 提高组] 合并果子 / [USACO06NOV] Fence Repair G 贪心 二叉堆 优先队列
- HUST 1214 Cubic-free numbers II(区间n=x^3*k的n的个数、枚举x容斥)
- 2021秋季《数据结构》_EOJ 1056.统计工龄
- leetcode-Algorithms-1056|易混淆数