poj2954Triangle
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的更多相关文章
随机推荐
- Redis 小调研
一. 概况: Redis是一款开源的.网络化的.基于内存的.可进行数据持久化的Key-Value存储系统.它的数据模型建立在外层,类似于其它结构化存储系统,是通过Key映射Value的方式来建立字典以 ...
- 安装Hama的基本过程
- 实时监听input输入情况
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- 安装memcached报错:If it's already installed, specify its path using --with-libevent=/dir/
一.安装memcached,执行./configure --prefix=/usr/local/memcached时候报错: 问题:If it's already installed, specify ...
- BOM的介绍
BOM的概念 BOM(Browser Object Model) 是指浏览器对象模型,浏览器对象模型提供了独立于内容的.可以与浏览器窗口进行互动的对象结构.BOM由多个对象组成,其中代表浏览器窗口的W ...
- NX二次开发-获取面的法向向量UF_MODL_ask_face_data
NX9+VS2012 #include <uf.h> #include <uf_modl.h> #include <uf_obj.h> #include <u ...
- APC注入DLL(win7下有问题)
void APCKernelRoutine(PKAPC pKAPC, PKNORMAL_ROUTINE pUserAPC, PVOID pContext, PVOID pSysArg1, PVOID ...
- idea 社区版+spring boot+ssm+swagger创建rest api
新手上路,出了好多错,记录一下 1.创建数据库:springBootSsmTest 2.打开IDEA创建 Spring boot项目:File——New——Project——Spring Assist ...
- centos6 & centos7搭建ntp服务器
原理 NTP(Network TimeProtocol,网络时间协议)是用来使计算机时间同步的一种协议.它可以使计算机对其服务器或时钟源做同步化,它可以提供高精准度的时间校正(LAN上与标准间差小于1 ...
- iOS开发UITouch触摸API简介
1.UITouch简介 当用户触摸屏幕时,会创建一个UITouch对象: UITouch的作用保存着触摸相关的信息,比如触摸的位置.时间.阶段等: 当从开始到结束,系统会更新UITouch对象,结束时 ...