传送门

Pick定理

定点坐标为整点的三角形,面积为S,边上的整点个数为L,三角形内部整点个数为N

S=N+L/2-1

 //Achen
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<cstdio>
#include<queue>
#include<cmath>
#include<set>
#include<map>
#define Formylove return 0
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Rep(i,a,b) for(int i=(a);i>=(b);i--)
typedef long long LL;
typedef double db;
using namespace std;
LL x[],y[]; template<typename T>void read(T &x) {
char ch=getchar(); x=; T f=;
while(ch!='-'&&(ch<''||ch>'')) ch=getchar();
if(ch=='-') f=-,ch=getchar();
for(;ch>=''&&ch<='';ch=getchar()) x=x*+ch-''; x*=f;
} db get_S(int x,int y,int xx,int yy) {
return abs(x*yy-xx*y)/2.0;
} LL gcd(LL a,LL b) { return !b?a:gcd(b,a%b); } db get_L(int x,int y,int xx,int yy) {
if(xx-x==&&yy-y==) return ;
if(xx-x==) return abs(yy-y)-;
if(yy-y==) return abs(xx-x)-;
return gcd(abs(x-xx),abs(y-yy))-;
} int main() {
#ifdef ANS
freopen(".in","r",stdin);
freopen(".out","w",stdout);
#endif
for(;;) {
read(x[]); read(y[]);
read(x[]); read(y[]);
read(x[]); read(y[]);
if(x[]==&&y[]==&&x[]==&&y[]==&&x[]==&&y[]==) break;
db S=get_S(x[]-x[],y[]-y[],x[]-x[],y[]-y[]);
db L=+get_L(x[],y[],x[],y[])+get_L(x[],y[],x[],y[])+get_L(x[],y[],x[],y[]);
db n=S-L/2.0+;
printf("%d\n",(int)n);
}
Formylove;
}

poj2954Triangle的更多相关文章

随机推荐

  1. 标准 IO 测试 标准输出,输入,出错缓冲大小;全缓冲文本流大小

    例子:测试缓冲区大小 #include <stdio.h> int main(int argc, const char *argv[]) { //标准输入大小,没有输入内容时,标准输入缓冲 ...

  2. shell脚本输出空心等腰三角形

    第一种:(for循环) #!/bin/bash#空心等腰三角形arr=9 #定义金字塔的层数for ((i=1;i<=$arr;i++))do for ((j=1;j<=$(($arr-$ ...

  3. 遍历对象不能通过for循环因为对象无序 可以通过for -n

    遍历对象不能通过for循环因为对象无序  可以通过for -n var json={ "name":“小明”, “age”:“10”, “sex”:"男" }; ...

  4. 实战ZeroMQ的PUSH/PULL推拉模式

    原文地址: http://ju.outofmemory.cn/entry/235976

  5. 快速失败and安全失败

    快速失败: 举个栗子: public static void main(String[] args) { ArrayList<String> list=new ArrayList<& ...

  6. C#中反射的基础基础基础

    class Program { static void Main(string[] args) { Type t = typeof(Student);//typeof(类) 取类的类型 并且存储在Ty ...

  7. Batch - FOR %%a %%b

    总结 %%a refers to the name of the variable your for loop will write to. Quoted from for /?: FOR %vari ...

  8. DataWorks2.0的“业务流程”与1.0的“工作流”的对比

    DatwWorks终于升级2.0了,心情万分激动之余,又有一丝担忧.因为,没法再创建新的旧版工作流了...新版抛弃了“工作流”这个概念,引入了“业务流程”和“解决方案”两个新的概念.于是,作为团队Le ...

  9. (转)mysql分区技术2

    转:http://database.51cto.com/art/201002/184392.htm 非整数列分区 任何使用过分区的人应该都遇到过不少问题,特别是面对非整数列分区时,MySQL 5.1只 ...

  10. HDU6395-Sequence 矩阵快速幂+除法分块 矩阵快速幂模板

    目录 Catalog Solution: (有任何问题欢迎留言或私聊 && 欢迎交流讨论哦 Catalog Problem:Portal传送门  原题目描述在最下面. Solution ...