zoukankan      html  css  js  c++  java
  • 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
    ");
            else printf("
    ");
        }
        return 0;
    }
  • 相关阅读:
    喵哈哈村的魔法考试 Round #1 (Div.2) 题解
    Codeforces Round #398 (Div. 2) A. Snacktower 模拟
    Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) F. Souvenirs 线段树套set
    视频人脸检测——Dlib版(六)
    pip/pip3更换国内源
    OpenCV添加中文(五)
    图片人脸检测——Dlib版(四)
    视频人脸检测——OpenCV版(三)
    Tesseract Ocr文字识别
    图片人脸检测——OpenCV版(二)
  • 原文地址:https://www.cnblogs.com/Felix-F/p/3251038.html
Copyright © 2011-2022 走看看