HDOJ 5448 Marisa’s Cake
来源:互联网 发布:linux文件夹 编辑:程序博客网 时间:2024/05/18 15:27
计算每一条线段对答案的贡献,然后用前缀和优化就行了。。。。
#include <bits/stdc++.h>using namespace std;typedef long long LL;const int maxn = 100005;const int mod = 1e9+7;struct Point{LL x, y;Point(LL x = 0, LL y = 0) : x(x), y(y) {}Point operator + (const Point &b) const {return Point((x + b.x) % mod, (y + b.y) % mod);}Point operator - (const Point &b) const {return Point((x - b.x + mod) % mod, (y - b.y + mod) % mod);}Point operator * (const LL t) const {return Point(x * t % mod, y * t % mod);}LL operator ^ (const Point &b) const {return (x * b.y % mod - y * b.x % mod + mod) % mod;}}S, p[maxn];LL two[maxn];int n;inline int c(int i, int j){return ((i - j - 1) % n + n) % n;}void work(){scanf("%d", &n);for(int i = 0; i < n; i++) scanf("%lld%lld", &p[i].x, &p[i].y);S = Point(0, 0);for(int i = 1; i < n; i++) S = S + p[i] * two[c(0, i)];LL ans = p[0] ^ S;for(int i = 1; i < n; i++) {S = S - p[i] * two[c(i-1, i)];S = S * 2LL;S = S + p[i-1];ans = (ans + (p[i] ^ S)) % mod;}printf("%lld\n", ans);}int main(){two[0] = 1;for(int i = 1; i <= 100000; i++) two[i] = two[i-1] * 2 % mod;int _;scanf("%d", &_);while(_--) work();return 0;}
0 0
- HDOJ 5448 Marisa’s Cake
- HDU 5448 Marisa’s Cake
- 【HDU 5448】Marisa’s Cake
- hdu 5448 Marisa’s Cake(几何+凸包)
- hdu 5448 Marisa’s Cake(计算几何加推公式)
- HDU 5448 Marisa's Cake(计算几何)
- HDU 5448 Marisa’s Cake(n个点中任意点组成的多边形面积之和)
- HDOJ 5640 king's cake
- HDOJ 5640 King's Cake
- hdoj-5640-King's Cake
- 2015 ACM/ICPC Asia Regional Changchun Online 1012 hdu5448 Marisa’s Cake
- hdu5448-Marisa’s Cake 构成的所有多边形面积的和
- HDOJ 5640-King's Cake【数学】
- hdoj King's Cake 5640 (模拟)
- NOJ [1118] Marisa's Affair
- hdoj 1722 Cake
- hdoj 1722 Cake 【GCD】
- hdoj-1722-Cake
- 干货 | Docker文件系统的分层与隔离
- StringUtil 简单用法
- Climbing Stairs
- Swift 分享多媒体消息到 微信/新浪微博/QQ
- Hibernate懒加载的三种解决方案
- HDOJ 5448 Marisa’s Cake
- [RFID]IC卡克隆(一)Proxmark3简介
- 纯CSS3制作皮卡丘动画壁纸
- python编程:使用opencv按一定间隔截取视频帧
- vector C语言详细用法的分析
- XMemcached与spring的集成实例
- IOS 获取,如电量,CPU,型号
- ajax实现二级联动_读取的是xml文件
- 响应式网页设计的9条基本原则