POJ 1654 Area 凸包面积
水题直接码...
/********************* Template ************************/ #include <set> #include <map> #include <list> #include <cmath> #include <ctime> #include <deque> #include <queue> #include <stack> #include <bitset> #include <cstdio> #include <string> #include <vector> #include <cassert> #include <cstdlib> #include <cstring> #include <sstream> #include <fstream> #include <numeric> #include <iomanip> #include <iostream> #include <algorithm> #include <functional> using namespace std; #define EPS 1e-8 #define MAXN (int)1e5+50 #define MOD (int)1e9+7 #define PI acos(-1.0) #define LINF ((1LL)<<50) #define INF (1<<30); #define max(a,b) ((a) > (b) ? (a) : (b)) #define min(a,b) ((a) < (b) ? (a) : (b)) #define max3(a,b,c) (max(max(a,b),c)) #define min3(a,b,c) (min(min(a,b),c)) #define BUG cout<<"BUG! "<<endl #define LINE cout<<"--------------"<<endl #define L(t) (t << 1) #define R(t) (t << 1 | 1) #define Mid(a,b) ((a + b) >> 1) #define lowbit(a) (a & -a) #define FIN freopen("in.txt","r",stdin) #define FOUT freopen("out.txt","w",stdout) #pragma comment (linker,"/STACK:102400000,102400000") // typedef long long LL; // typedef unsigned long long ULL; typedef __int64 LL; // typedef unisigned __int64 ULL; // int gcd(int a,int b){ return b?gcd(b,a%b):a; } // int lcm(int a,int b){ return a*b/gcd(a,b); } /********************* F ************************/ struct POINT{ double x,y; POINT(double _x = 0, double _y = 0):x(_x),y(_y){}; void show(){ cout<<x<<" "<<y<<endl; } }p[MAXN]; double dist(POINT p1,POINT p2){ return(sqrt((p1.x-p2.x) * (p1.x-p2.x) + (p1.y-p2.y) * (p1.y-p2.y))); } double multiply(POINT sp,POINT ep,POINT op){ return (sp.x-op.x) * (ep.y-op.y) - (ep.x-op.x) * (sp.y-op.y); } bool ptcmp(POINT a,POINT b){ if(multiply(a,b,p[0]) == 0) return dist(p[0],a) < dist(p[0],b); return (multiply(a,b,p[0]) > 0); } double Triangle_area(POINT a,POINT b,POINT c){ return multiply(a,b,c)/2; } char a[1000005]; double ax[10] = {0,-1,0,1,-1,0,1,-1,0,1}; double ay[10] = {0,-1,-1,-1,0,0,0,1,1,1}; int main() { //FIN; //FOUT; int T; scanf("%d",&T); getchar(); while(T--){ gets(a); int len = strlen(a); double ans = 0; POINT st = POINT(0,0); for(int i = 0 ; i < len-2 ; i++){ POINT st1 = POINT(st.x+ax[a[i]-'0'],st.y+ay[a[i]-'0']); POINT st2 = POINT(st1.x+ax[a[i+1]-'0'],st1.y+ay[a[i+1]-'0']); ans += Triangle_area(POINT(0,0),st1,st2); st = st1; } ans = fabs(ans); printf("%I64d",LL(ans)); if((ans - floor(ans)) >= EPS) printf(".5\n"); else printf("\n"); } return 0; }
分类:
计算几何
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 智能桌面机器人:用.NET IoT库控制舵机并多方法播放表情
· Linux glibc自带哈希表的用例及性能测试
· 深入理解 Mybatis 分库分表执行原理
· 如何打造一个高并发系统?
· .NET Core GC压缩(compact_phase)底层原理浅谈
· 新年开篇:在本地部署DeepSeek大模型实现联网增强的AI应用
· DeepSeek火爆全网,官网宕机?本地部署一个随便玩「LLM探索」
· Janus Pro:DeepSeek 开源革新,多模态 AI 的未来
· 互联网不景气了那就玩玩嵌入式吧,用纯.NET开发并制作一个智能桌面机器人(三):用.NET IoT库
· 上周热点回顾(1.20-1.26)