コード例 #1
0
void mprint (poly &P) {
    int mmax = 0;
    int n = P.size();
    cout<<n<<endl;
    for (int i = 1; i < n; ++i ) {

        if (mfunc(P[mmax], P[i])) {
            mmax = i;
        }
    }
    //cout<<mmax<<endl;
    cout<<P[mmax].x<<" "<<P[mmax].y<<endl;
    int i = (mmax-1+n)%n;
    while(i != mmax) {
      //  cout<<i<<endl;
        cout<<P[i].x<<" "<<P[i].y;
        cout<<endl;
        i = (i-1+n)%n;
    }
}
コード例 #2
0
ファイル: 10245.cpp プロジェクト: henviso/contests
double closest_pair (poly &P) {
	int n = P.size();
	double d = norma(P[0]-P[1]);
	a = P[0].id; b = P[1].id;
	set<point, bool(*)(point,point)> s(&ycmp);
	sort(all(P));
	for(int i=0,j=0 ; i<n ; i++) {
		point lower(0, P[i].y - d) , upper(0, P[i].y + d);
		while(P[i].x - P[j].x > d)
		s.erase(P[j++]);
		foreach(p, s.lower_bound(lower), s.upper_bound(upper))
		/* os pontos mais proximos sao tirados de P[i] e *p */
		if(d > norma(P[i] - *p)){
			d = norma(P[i] - *p);
			a = p->id;
			b = P[i].id;
		}
		s.insert(P[i]);
	}
	return d;
}
コード例 #3
0
ファイル: polynomial.hpp プロジェクト: cbrooks90/Tableaux
poly<T> invlogrev(poly<T> const& p) {
  size_t const d = p.size(); size_t i;
  poly<T> s = p; s.pop_front();
  poly<T> r(0,1);
  r.push_back(T(-1)*s[0]);
  poly<T> rinv, m = r;
  for (size_t n=2; n<=d; n*=2) {
    m.diff();
    rinv = invert(r,2*n-1);
    m *= rinv;
    m += s;
    m.first(2*n-1);
    m *= T(-1);
    for (i=0; i!=m.size(); ++i)
      m[i] /= i+1;
    m.push_front(T(1));
    m *= r; m.first(2*n);
    r = m;
  }
  r.first(d); r.rev(d-1);
  return r;
}
コード例 #4
0
ファイル: Submarines_3023old.cpp プロジェクト: jdumas/acm
bool is_inside(const point & a, const poly & p) {
	int i,n=p.size(),k=0;
	point s, e (1001,1001);
	double d;
	bool tmp, nb_inter = true;
	/* Manière propre, mais peu efficace,
	de trouver un "bon" point en dehors du poly */
	/*for (i = 0; i < n; i++) {
		d = det(e-a, p[i]-a);
		if (d == 0.) {
			e.real()++;
			i = 0;
		}
	}*/
	for (i = 0; i < n; i++) {
		tmp = interserct(a,e,p[i], p[(i+1) % n]);
		nb_inter = (nb_inter != tmp);
		if (tmp) k++;
	}
	cout << nb_inter;
	cout << k << endl;
	return nb_inter;
}
コード例 #5
0
ファイル: polynomial.hpp プロジェクト: cbrooks90/Tableaux
poly<T> logrev(poly<T> const& p, size_t const n) {
  size_t const d = p.size()-1;
  poly<T> c = p, b = p;
  c.diff(); c.rev(d-1);
  b.rev(d);
  poly<T> b0 = invert(b, d);
  c *= b0; c.first(d);
  poly<T> out = c, newc;
  for (size_t i=1; i <= n/d; ++i) {
    newc = b;
    newc *= c; newc.remove(d);
    newc *= b0; newc.first(d);
    newc *= T(-1);
    c = newc;
    //Improve efficiency by making this a member function and directly
    //appending 'rep' here
    newc *= poly<T>(d*i);
    out += newc;
  }
  while (out.size() > n) out.pop_back();
  while (out.size() < n) out.push_back(T(0));
  return out;
}
コード例 #6
0
ファイル: wto.cpp プロジェクト: vipulharsh/Coding
poly subt(poly p1,poly p2){
	if(p1.size()>=p2.size()){
		for(int i=0;i<p2.size();i++){
			p1[i]-=p2[i];
		}
		return p1;
	}
	else{
		for(int i=0;i<p1.size();i++){
			p2[i]=p1[i]-p2[i];
		}
		for(int i=p1.size();i<p2.size();i++){
			p2[i]=-p2[i];
		}

		return p2;
	}
}
コード例 #7
0
ファイル: polynomial.hpp プロジェクト: cbrooks90/Tableaux
bool poly<T>::operator==(poly<T> const& rhs) const {
  if (this->size() != rhs.size()) return false;
  int i; for (i=0; i<=rhs.size(); ++i)
    if ((*this)[i] != rhs[i]) return false;
  return true;
}
Double eval(const poly & p, Double x) {
  Double res = 0;
  for (int i = 0; i < (int)p.size(); i++)
    res += p[i].first * powl(x, p[i].second);
  return res;
}
コード例 #9
0
bool can_place(int x,int y,const poly &p)
{
    for(int i=0;i<p.size();i++)
        if(now[x+p[i].x][y+p[i].y]!='Z') return 0 ;
    return 1 ;
}
コード例 #10
0
bool equ(const poly &v1,const poly &v2)
{
    for(int i=0;i<v1.size();i++)
        if(v1[i]!=v2[i]) return 0 ;
    return 1 ;
}
コード例 #11
0
ファイル: wto.cpp プロジェクト: vipulharsh/Coding
void printpoly(poly p){
	for(int i=0;i<p.size();i++){
		cout<<" + "<<p[i]<<"x^"<<i;
	}
	cout<<endl;
}
コード例 #12
0
ファイル: B.cpp プロジェクト: lucassf/UVA-Solutions
inline void reduce(poly &a){
    int N = (int)a.size();

    while (N > 0 && a[N - 1] == 0)a.pop_back(), N--;
}
コード例 #13
0
ファイル: B.cpp プロジェクト: lucassf/UVA-Solutions
void printPol(poly &a){
    for (int i = 0; i < (int)a.size(); i++){
        cout<<a[i]<<" ";
    }
    cout<<endl;
}