博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj 1809
阅读量:4310 次
发布时间:2019-06-06

本文共 1425 字,大约阅读时间需要 4 分钟。

///一个点的坐标只有四种可能,用0表示 偶数,1表示奇数 ,则四种可能为(0,0),(0,1)  ///(1,0),(1,1)。观察公式A=|x1y2 - y1x2 + x2y3 - y2x3 + x3y1 - y3x1|/2,仔细分析之后  ///可以得到A要为偶数,那么三个点的坐标中至少要有两个点的类型一样,这样就可以将问题的  ///复杂度降到O(1)了。   #include
int main() { int cas,t=1; scanf("%d",&cas); while(cas--) { printf("Scenario #%d:\n",t++); long n,x,y,i; long long a[2][2]={0,0,0,0},num=0; scanf("%ld",&n); for(i=0;i
>1][i&1]; num+=temp*(temp-1)*(temp-2)/6+temp*(temp-1)*(n-temp)/2; } printf("%lld\n\n",num); } return 0; } /* 向量AB=((X2-X1),(Y2-Y1)),向量AC=((X3-X1),(Y3-Y1)) 三角形面积=|(X2-X1)(Y3-Y1)-(X3-X1)(Y2-Y1)| 即为向量表示|X2-X1 X3-X1| |Y2-Y1 Y3-Y1| */ ///下面是在网上找到的程序,程序很简练,一些用法也很有技巧,学习下,以后学会使用 /*#include
using namespace std; int a[4][2]={0,0,0,1,1,0,1,1}; long long b[2][2]; int main() { int N,i=0,x,y,M,j; long long ans,t; for(scanf("%d",&N);N--;printf("Scenario #%d:\n%lld\n\n",++i,ans)) { scanf("%d",&M); for(b[0][0]=b[0][1]=b[1][0]=b[1][1]=j=0;j
>1][j&1]; ans+=t*(t-1)*(t-2)/6+t*(t-1)*(M-t)/2; //C(t,3)+C(t,2)*(M-t) } } return 0; } */

转载于:https://www.cnblogs.com/zhanglanyun/archive/2011/06/24/2089313.html

你可能感兴趣的文章
量化策略回测DCCV2
查看>>
mongodb查询优化
查看>>
五步git操作搞定Github中fork的项目与原作者同步
查看>>
git 删除远程分支
查看>>
删远端分支报错remote refs do not exist或git: refusing to delete the current branch解决方法
查看>>
python multiprocessing遇到Can’t pickle instancemethod问题
查看>>
APP真机测试及发布
查看>>
通知机制 (Notifications)
查看>>
10 Things You Need To Know About Cocoa Auto Layout
查看>>
一个异步网络请求的坑:关于NSURLConnection和NSRunLoopCommonModes
查看>>
iOS 如何放大按钮点击热区
查看>>
ios设备唯一标识获取策略
查看>>
获取推送通知的DeviceToken
查看>>
Could not find a storyboard named 'Main' in bundle NSBundle
查看>>
CocoaPods安装和使用教程
查看>>
Beginning Auto Layout Tutorial
查看>>
block使用小结、在arc中使用block、如何防止循环引用
查看>>
iPhone开发学习笔记002——Xib设计UITableViewCell然后动态加载
查看>>
iOS开发中遇到的问题整理 (一)
查看>>
Swift code into Object-C 出现 ***-swift have not found this file 的问题
查看>>