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的更多相关文章
随机推荐
- Spring接收数据,传递数据
Spring接收数据,传递数据 前提配置 POM <dependency> <groupId>org.springframework</groupId> < ...
- could not load the tomcat server configuration ...
参考文档: https://blog.csdn.net/u013381651/article/details/51567758 问题解决. 原因是你把项目里的tomcat的server项目也关闭了, ...
- Linux 错误: $'\r': command not found
是linux无法解析$'\r'.这其实是windows与linux系统的差异导致的. 因为linux上的换行符为\n,而windows上的换行符为\r\n.所以脚本到linux上就无法解析了. 通常的 ...
- Vue Router高级
路由组件传参 通过props解耦 const User = { props: ['id'], template: '<div>User {{ id }}</div>' } co ...
- 使用babel转码器,让浏览器支持es6语法
ECMAScript 6.0(以下简称 ES6)是 JavaScript 语言的下一代标准,可是很多浏览器并不支持es6语法,所以我们需要一个转码工具, 把es6的语法转换成浏览器支持的javascr ...
- JAVA错误:Exception in thread "main" java.lang.NullPointerException
JAVA错误:Exception in thread "main" java.lang.NullPointerException例如: Exception in thread &q ...
- delphi RTL是什么?
第一种解释: RTL Run-Time Library,支持程序运行执行的函数库.是运行时间库,在运行时需要.Delphi的RTL包括System,SysUtils,Math三个单元RTL提供的大部分 ...
- 56 Marvin: 一个支持GPU加速、且不依赖其他库(除cuda和cudnn)的轻量化多维深度学习(deep learning)框架介绍
0 引言 Marvin是普林斯顿视觉实验室(PrincetonVision)于2015年提出的轻量化GPU加速的多维深度学习网络框架.该框架采用纯c/c++编写,除了cuda和cudnn以外,不依赖其 ...
- eclipse打包插件net.sf.fjep.fatjar
eclipse打包插件安装 1)将net.sf.fjep.fatjar_0.0.32.jar拷贝到eclipse安装目录中的plugins目录下,然后重启eclipse即可. 软件获取方式: 链接:h ...
- NSDateFormatter 今年日期格式化成字符串是明年日期问题?
在项目里我要是把NSDate格式化成字符串 我的format是@"YYYY年MM月dd日 HH:mm" 传入日期2013-12-30 15:00:00后,返回给我的字符串是 201 ...