这道题就是计算三角形里面的格点的个数, 可以用匹克定理, s = n + b/2 - 1; 其中s是格点多边形的面积, n是多边形内部的格点数目, b是边界上的格点,假设有两个坐标(x1, y1) (x2, y2) b = gcd(abs(x1-x2), (y1-y2)).代码如下:/* ...
分类:
其他好文 时间:
2016-01-05 12:38:40
阅读次数:
134
题目的意思就是给你一个图, 输出他的欧拉路(欧拉通路 或者 欧拉回路),无向图欧拉回路判断条件是:1:图连通 2:所有点的度数为偶数 无向图欧拉通路的条件是:1:图连通 2:有且只有两个点的度数为奇数, 不过寻找欧拉路的代码是一样的,学习了新的建图方法,代码如下:/* ID: m150...
分类:
其他好文 时间:
2016-01-01 20:59:59
阅读次数:
183
There is a fence with n posts, each post can be painted with one of the k colors.You have to paint all the posts such that no more than two adjacent f...
分类:
其他好文 时间:
2015-12-25 06:26:55
阅读次数:
194
http://poj.org/problem?id=1037题意:输入木棒的个数n,其中每个木棒长度等于对应的编号,把木棒按照波浪形排序,然后输出第c个;分析:总数为i跟木棒中第k短的木棒 就等于总数为i-1中比这一根短的方案数 + 和比这一根长的方案数;最后用一个三维数组表示成c[i][k][up...
分类:
编程语言 时间:
2015-12-22 13:08:11
阅读次数:
172
<?xmlversion="1.0"?><clusterconfig_version="57"name="HA"><clusternodes><clusternodename="cluster1"nodeid="1"><fence><methodname="1"><devicename="VBoxManage"vmname="Cluster1"/></method></fence></cluste..
分类:
其他好文 时间:
2015-11-21 07:16:55
阅读次数:
151
Fencing the CowsHal BurchFarmer John wishes to build a fence to contain his cows, but he's a bit short on cash right. Any fence he builds must contain...
分类:
其他好文 时间:
2015-11-15 17:40:54
阅读次数:
199
题意:如果要切断一个长度为a的木条需要花费代价a, 问要切出要求的n个木条所需的最小代价。思路:模拟huffman树,每次选取最小的两个数加入结果,再将这两个数的和加入队列。注意priority_queue的用法,原型:1 priority_queue q; 2 priority_queue,Co....
分类:
其他好文 时间:
2015-11-12 21:55:33
阅读次数:
245
水题#include#include#include#includeusing namespace std;const double PI=3.1415926;int main(){ double L; while(~scanf("%lf",&L)){ if(!L) bre...
分类:
其他好文 时间:
2015-11-11 10:03:34
阅读次数:
180
一直纠结在fence 和 原子操作。记住:原子操作是当多个thread 准备对同一个数据进行写操作,原子操作的目的是保证该数据只被一个thread 读、修改、写。这三个步骤不会受其他thread影响。fence 是保证thread 对 数据的修改被其他thread发现,发现后,该thread 继续向...
分类:
其他好文 时间:
2015-10-22 00:15:44
阅读次数:
658
题目连接http://poj.org/problem?id=3253Fence RepairDescriptionFarmer John wants to repair a small length of the fence around the pasture. He measures the f...
分类:
其他好文 时间:
2015-10-14 00:07:16
阅读次数:
288