Example #1
0
main()
{
    int n,l;
    while(1)
    {
        q1=_q[0],q2=_q[1];
        heap.n=1;
        test.set();
        test.get();
        scanf("%d",&n);
        test.ball=n;
        /*open(test);
        node=20;
        while(heap.n>1 && heap.n<9000 && node--)
            open(heap.exmin());*/
        best.set();
        best.score=2147483647;
        // Greedy Search
        /*while(test.num>0)
        {
            best.set();
            best.score=2147483647;
            if(best.pn>0)
            {
                test.add(best.path[0].x,best.path[0].y);
                printf("%d %d\n",best.path[0].x+1,best.path[0].y+1);
            }*/

        tp[5]=test;
        dfs(5,0,0);
        //}
        //----------------------------------------------------------------
        best.print();
    }
}
Example #2
0
File: 198c.cpp Project: 199911/acm
int main() {
  st.eat();
  scanf( "%lf", &vp );
  cur.eat();
  scanf( "%lf%lf", &v, &r );
  R = st.mag();
  o = vp / R;
  s = ang( st );
  t = ang( cur );

  Q = t - s;
  while ( Q < -EPS ) Q += 2 * PI;

  double up = 1e9, lo = 0;

  while ( up > lo + 1e-10 ) {
    double mid = (up + lo) / 2.0;

    double ang = s + o * mid;

    P p = P( R * cos(ang), R * sin(ang) );

    double d = dist( p, cur );

    if ( d < mid * v + EPS ) {
      up = mid;
    } else {
      lo = mid;
    }
  }

  printf( "%.9f\n", up);

	return 0;
}
Example #3
0
File: main.cpp Project: CCJY/coliru
 void next_permutation(){
     p.rotate(1);
     int i=1;
     while (++count[i] > i){
         count[i++] = 0;
         p.rotate( i );
     }
 }
		void restore() {
			switch (u8.type) {
				case Variant::U8: return u8.restore();
				case Variant::U16: return u16.restore();
				case Variant::U32: return u32.restore();
				case Variant::U64: return u64.restore();
				case Variant::U128: return u128.restore();
				default: SYSLOG("patcher @ unsupported patch type %d, cannot restore", static_cast<int>(u8.type));
			}
		}
Example #5
0
int main() {
    int T;
    scanf("%d", &T);
    while (T--) {
        double x1, y1, x2, y2, x3, y3;
        scanf("%lf%lf", &x1, &y1);
        scanf("%lf%lf", &x2, &y2);
        scanf("%lf%lf", &x3, &y3);
        const P p = center(P(x1, y1), P(x2, y2), P(x3, y3));
        printf("%.3f %.3f %.3f\n", p.real(), p.imag(), abs(p-P(x1, y1)));
    }
    return 0;
}
Example #6
0
 double solve()  
 {  
     u.read();v.read();  
     int k1,k2;  
     k1=mid((u-v).angle());  
     k2=mid((v-u).angle());  
     double t1=(u-v)*(p[k1]-v);  
     double t2=(u-v)*(p[k2]-v);  
     if(t1*t2>-eps)return 0.0;  
     double s1,s2;  
     P a,b;  
     s1=s2=0.0;  
     a=calc(k1,k2,s1,s2);  
     b=calc(k2,k1,s2,s1);  
     s1+=a*b;  
     s2+=b*a;  
     return min(s1,s2)/2.0;  
 }  
Example #7
0
int main() {
    int m, n, k;
    int isUp = -1;
    cin >> m >> n >> k;
    p_m.totalNums = m;
    p_n.totalNums = n;
    for (int i=0; i<k; i++) {
        double tmp;
        cin >> tmp;
        double pm = p_m.add(tmp);
        double pn = p_n.add(tmp);
        if (i+1 >= n) {
            if (pm > pn && isUp != 1) {
                isUp = 1;
                cout << "BUY ON DAY " << i+1 << endl;
            } else if (pm < pn && isUp != 0) {
                isUp = 0;
                cout << "SELL ON DAY " << i+1 << endl;
            }
        }
    }
    return 0;
}
Example #8
0
int main()
{
  sf("%d%d%d%d",&xa,&ya,&xb,&yb);
  sf("%d",&n);
  ren[1].x=xa;ren[1].y=ya;
  ren[2].x=xb;ren[2].y=ya;
  ren[3].x=xa;ren[3].y=yb;
  ren[4].x=xb;ren[4].y=yb;
  k=4;
  for (i=min(ya,yb)+1;i<=max(ya,yb)-1;i++)
  {
    k++;
    ren[k].x=xa;ren[k].y=i;
    k++;
    ren[k].x=xb;ren[k].y=i;
  }
  for (i=min(xa,xb)+1;i<=max(xa,xb)-1;i++)
  {
    k++;
    ren[k].x=i;ren[k].y=ya;
    k++;
    ren[k].x=i;ren[k].y=yb;
  }
  for (i=1;i<=n;i++)
  {
    dian.input();
    sf("%d",&r);
    for (j=1;j<=k;j++)
      if (dst(dian,ren[j])<=r)
        ff[j]=1;
  }
  for (i=1;i<=k;i++)
    if (!ff[i])
      m++;
  cout<<m<<endl;
  return 0;
}
Example #9
0
void PlayerInfo::onReceiveCommand(int32_t clientId, sf::Packet& packet)
{
    if (clientId != this->clientId) return;
    int16_t command;
    packet >> command;
    switch(command)
    {
    case CMD_UPDATE_CREW_POSITION:
        {
            int32_t position;
            bool active;
            packet >> position >> active;
            crew_position[position] = active;
            
            if (isMainScreen())
                main_screen_control = false;
            if (active && mySpaceship)
            {
                int main_screen_control_cnt = 0;
                foreach(PlayerInfo, i, playerInfoList)
                {
                    if (i->ship_id == mySpaceship->getMultiplayerId() && i->main_screen_control)
                        main_screen_control_cnt++;
                }
                if (main_screen_control_cnt == 0)
                    main_screen_control = true;
            }
        }
        break;
    case CMD_UPDATE_SHIP_ID:
        packet >> ship_id;
        break;
    case CMD_UPDATE_MAIN_SCREEN_CONTROL:
        packet >> main_screen_control;
        break;
    }
Example #10
0
 double _distance(const P& lhs, const P& rhs)
 {
     const P d = lhs - rhs;
     return std::sqrt(d.x() * d.x() + d.y() * d.y());
 }
Example #11
0
 void input()
 {
   s.input();e.input();
 }
Example #12
0
 void print() {
     cerr << p.real() << " " << p.imag() << " " << r << endl;
 }
Example #13
0
 void print() {
     cerr << "{(" << a.real() << ", " << a.imag() << "), (" << b.real() << ", " << b.imag() << ")}" << endl;
 }
Example #14
0
    const std::string toString() const {
        std::stringstream ss;
        ss << "Point(" << myPoint.toString() << ")";

        return ss.str();
    }
Example #15
0
 const std::shared_ptr<const ConvexCCWPolygon> translate(P p) const {
     return std::shared_ptr<const ConvexCCWPolygon>(
                new Point(P(myPoint.gX() + p.gX(), myPoint.gY() + p.gY())));
 }
Example #16
0
 const C &input() { 
     mid.input(); 
     scanf("%lf", &r); 
     return *this;
 } 
Example #17
0
int main()
{
  freopen("ti.in","r",stdin);
  scanf("%d",&zu);
  for (zz=1;zz<=zu;zz++)
  {
    yuan.input();
    scanf("%d%d",&n,&m);
    for (i=1;i<=n;i++)
    {
      dian[i].input();
      dis[i]=dst(yuan,dian[i]);
      scanf("%d%d",&shi[i],&shu[i]);
    }
    memset(ff,-1,sizeof(ff));
    memset(cc,0,sizeof(cc));
    c=0;
    for (i=1;i<=n;i++)
    {
      if (ff[i]!=-1)
        continue;
      c++;
      SEG ss(yuan,dian[i]);
      for (j=1;j<=n;j++)
        if (ol(ss,dian[j]))
        {
          cc[c]++;
          she[c][cc[c]]=j;
        }
      sort(&she[c][1],&she[c][cc[c]+1],cmp);
      ff[she[c][1]]=0;
      shuh[c][1]=shu[she[c][1]];
      shih[c][1]=shi[she[c][1]];
      for (j=2;j<=cc[c];j++)
      {
        ff[she[c][j]]=she[c][j-1];
        shuh[c][j]=shuh[c][j-1]+shu[she[c][j]];
        shih[c][j]=shih[c][j-1]+shi[she[c][j]];
      }
      tou[c]=she[c][cc[c]];
    }
    for (i=1;i<=m;i++)
      f[0][i]=-1;
    f[0][0]=0;
    for (i=1;i<=c;i++)
    {
      f[i][0]=0;
      for (j=0;j<=m;j++)
      {
        if (f[i-1][j]!=-1)
          f[i][j]=f[i-1][j];
        else
          f[i][j]=-1;
        for (k=1;k<=cc[i];k++)
          if (j>=shih[i][k]&&f[i-1][j-shih[i][k]]!=-1)
            f[i][j]=max(f[i][j],f[i-1][j-shih[i][k]]+shuh[i][k]);
      }
    }
    mm=0;
    for (i=0;i<=m;i++)
      mm=max(mm,f[c][i]);
    cout<<mm<<endl;
  }
  return 0;
}