USACO3.43Electric Fence(pick定理)
忘记pick定理是什么了 想枚举来着 。。没枚出来
有篇pick定理的证明 貌似挺好 也没太看懂
/*
ID: shangca2
LANG: C++
TASK: fence9
*/
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
using namespace std;
int gcd(int x,int y)
{
return y==?x:gcd(y,x%y);
}
int main()
{
freopen("fence9.in","r",stdin);
freopen("fence9.out","w",stdout);
int n,m,p,k=,ans;
double s;
cin>>n>>m>>p;
s = p*m/2.0;
k+=p;
k+=gcd(n,m);
k+=abs(gcd(n-p,m));
ans = (s+)-k/;
cout<<ans<<endl;
return ;
}
USACO3.43Electric Fence(pick定理)的更多相关文章
- HDU 3775 Chain Code ——(Pick定理)
Pick定理运用在整点围城的面积,有以下公式:S围 = S内(线内部的整点个数)+ S线(线上整点的个数)/2 - 1.在这题上,我们可以用叉乘计算S围,题意要求的答案应该是S内+S线.那么我们进行推 ...
- 【POJ】2954 Triangle(pick定理)
http://poj.org/problem?id=2954 表示我交了20+次... 为什么呢?因为多组数据我是这样判断的:da=sum{a[i].x+a[i].y},然后!da就表示没有数据了QA ...
- UVa 10088 - Trees on My Island (pick定理)
样例: 输入:123 16 39 28 49 69 98 96 55 84 43 51 3121000 10002000 10004000 20006000 10008000 30008000 800 ...
- Area(Pick定理POJ1256)
Area Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 5429 Accepted: 2436 Description ...
- poj 2954 Triangle(Pick定理)
链接:http://poj.org/problem?id=2954 Triangle Time Limit: 1000MS Memory Limit: 65536K Total Submissio ...
- poj 1265 Area (Pick定理+求面积)
链接:http://poj.org/problem?id=1265 Area Time Limit: 1000MS Memory Limit: 10000K Total Submissions: ...
- poj1265Area(pick定理)
链接 Pick定理是说,在一个平面直角坐标系内,如果一个多边形的顶点全都在格点上,那么这个图形的面积恰好就等于边界上经过的格点数的一半加上内部所含格点数再减一. pick定理的一些应用 题意不好懂, ...
- pick定理:面积=内部整数点数+边上整数点数/2-1
//pick定理:面积=内部整数点数+边上整数点数/2-1 // POJ 2954 #include <iostream> #include <cstdio> #include ...
- UVa 10088 (Pick定理) Trees on My Island
这种1A的感觉真好 #include <cstdio> #include <vector> #include <cmath> using namespace std ...
随机推荐
- android线程池ThreadPoolExecutor的理解
android线程池ThreadPoolExecutor的理解 线程池 我自己理解看来.线程池顾名思义就是一个容器的意思,容纳的就是ThreadorRunable, 注意:每一个线程都是需要CPU分配 ...
- 软件工程——UML简介
UML概述: UML是对OMT(对象建模技术).Booth(Booch方法)以及OOSE(面向对象的软件工程)等记号系统实施统一工作后得到的一种记号系统. UML(Unified Modeling L ...
- Come and join us at English corner
2012.12.26 Hi all, How are you doing? Merry post-Christmas and happy upcoming New year!! I wish you ...
- 判断是否为闰年(bool)
bool为布尔型,只有一个字节,取值false和true #include<iostream>using namespace std;int main(){ int year; bool ...
- 解决 cocoapods diff: /../Podfile.lock: No such file or directory 问题
解决cocoapods diff: /../Podfile.lock: No such file or directory google一圈之后,找到两个解决方案: 方案一: 关闭Xcode,重新执 ...
- Linux消息队列
#include <stdio.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/ms ...
- time.h文件中包含的几个函数使用时须注意事项
time.h头文件中包含以下函数 char* asctime(const struct tm *tm); char* asctime_r(const struct tm *tm,char *buf); ...
- Installshield: custom action return value
参考:MSDN: Custom Action Return Values 参考:MSDN: Logging of Action Return Values
- awk 查找文件长度 删除
#在某个目录下,由于有些是缓存文件,它们的共同点就是长度大于3, 找到它们,然后用rm 命令删除#ls abc.pyabcd.py.... #ls | awk 'length($1) > 3 { ...
- 《sed的流艺术之三》-linux命令五分钟系列之二十三
本原创文章属于<Linux大棚>博客,博客地址为http://roclinux.cn.文章作者为rocrocket. 为了防止某些网站的恶性转载,特在每篇文章前加入此信息,还望读者体谅. ...