【题目链接】:http://acm.hdu.edu.cn/showproblem.php?pid=2108
【题意】
【题解】
逆时针;
可以想象一下;
如果是凸多边形的话;
逆时针的相邻的两条边;
前一条和后一条(逆时针意义上的“后一条”)边所代表的向量;
如果做叉积的话;
其结果肯定是指向屏幕外面的;
如果突然变成凹的了;
再做叉乘的话;
指向是屏幕里面的了;
也就是说如果是凸多边形的话;
叉乘的结果应该都为正数;
【Number Of WA】
0
【完整代码】
#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ms(x,y) memset(x,y,sizeof x)
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 11000;
struct point
{
double x,y;
};
double chaji(point a,point b)
{
double x1 = a.x,y1 = a.y;
double x2 = b.x,y2 = b.y;
return x1*y2-x2*y1;
}
int n;
point a[N];
int main()
{
//freopen("F:\rush.txt","r",stdin);
ios::sync_with_stdio(false);
while (cin >> n)
{
if (n==0) break;
rep1(i,1,n)
cin >> a[i].x >> a[i].y;
a[n+1]=a[1],a[n+2]=a[2];
bool fi = false;
rep1(i,1,n)
{
point v1 = point{a[i+1].x-a[i].x,a[i+1].y-a[i].y};
point v2 = point{a[i+2].x-a[i+1].x,a[i+2].y-a[i+1].y};
if (chaji(v1,v2)<0) fi = true;
}
if (fi)
cout <<"concave"<<endl;
else
cout <<"convex"<<endl;
}
//printf("
%.2lf sec
", (double)clock() / CLOCKS_PER_SEC);
return 0;
}