题面描述
思路
瞎枚举算面积就好了。
(一点技术含量都没有)
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<cstring>
#define ll long long
using namespace std;
const int N=1e6+10;
struct node{double x,y;}p0;
double mul(node p1,node p2,node p0)
{
double x1=p1.x-p0.x,y1=p1.y-p0.y;
double x2=p2.x-p0.x,y2=p2.y-p0.y;
return x1*y2-x2*y1;
}
node now,last;
double x,y,ans;
char slast;
char s[N];
int main()
{
int t;scanf("%d",&t);p0.x=0.0,p0.y=0.0;
while(t--)
{
scanf("%s",s+1);
int len=strlen(s+1);
x=0.0;y=0.0;ans=0;
for(int i=1;i<len;i++)
{
if(s[i]=='8')y++;
else if(s[i]=='2')y--;
else if(s[i]=='6')x++;
else if(s[i]=='4')x--;
else if(s[i]=='9')x++,y++;
else if(s[i]=='7')x--,y++;
else if(s[i]=='3')x++,y--;
else x--,y--;
if(slast!=s[i])
{
if(i>=3)ans+=mul(last,now,p0);
last.x=now.x,last.y=now.y;
}
now.x=x,now.y=y;
slast=s[i];
}
ans=fabs(ans);
printf("%lld",(ll)ans>>1);
if((ll)ans&1)puts(".5");
else puts("");
}
return 0;
}