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 = , double _y = ):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[]) == ) return dist(p[],a) < dist(p[],b);
return (multiply(a,b,p[]) > );
}
double Triangle_area(POINT a,POINT b,POINT c){
return multiply(a,b,c)/;
}
char a[];
double ax[] = {,-,,,-,,,-,,};
double ay[] = {,-,-,-,,,,,,};
int main()
{
//FIN;
//FOUT;
int T;
scanf("%d",&T);
getchar();
while(T--){
gets(a);
int len = strlen(a);
double ans = ;
POINT st = POINT(,);
for(int i = ; i < len- ; i++){
POINT st1 = POINT(st.x+ax[a[i]-''],st.y+ay[a[i]-'']);
POINT st2 = POINT(st1.x+ax[a[i+]-''],st1.y+ay[a[i+]-'']);
ans += Triangle_area(POINT(,),st1,st2);
st = st1;
}
ans = fabs(ans);
printf("%I64d",LL(ans));
if((ans - floor(ans)) >= EPS)
printf(".5\n");
else printf("\n");
}
return ;
}
上一篇:配置Nginx支持ThinkPHP的URL重写和PATHINFO


下一篇:Java 9将采用新的版本字符串格式