Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

再次希望哪位帮忙看看 !

Posted by nuciedh at 2007-08-10 21:45:37 on Problem 3327
In Reply To:RE个没完 ? 谁帮偶看看 ? 感激不尽 Posted by:nuciedh at 2007-08-09 23:30:37
> #include <cstdio>
> #include <algorithm>
> using namespace std;
> 
> struct atype
> {
>     int x1, y1, x2, y2, area;
>     void cut (int);
> };
> 
> int n, w, d, rear;
> atype space[1100], x, y;
> 
> bool operator < (const atype &a, const atype &b)
> {
>     return a.area < b.area;
> }
> 
> void atype :: cut (int s)
> {
>     int i;
>     i = 0;
>     /*
>     while (s > 0)
>     {
>         if (i % 2 == 0) s -= x2 - x1;
>         else            s -= y2 - y1;
>         i ++;
>     }
>     */
>     int t1, t2;
>     t1 = s / (x2 - x1 +  y2 - y1);
>     t2 = s % (x2 - x1 +  y2 - y1);
>     if (t1 & 1 == 0)
>     {
>         if (t2 < w) i = 2, s = t2;
>         else        i = 1, s = y2 - y1 - (t2 - w);
>     }
>     else
>     {
>         if (t2 < w) i = 2, s = x2 - x1 - t2;
>         else        i = 1, s = t2 - w;
>     }
>     
>     int a1, a2;
>     if (i % 2 == 0)
>     {
>         if (s < 0) s += x2 - x1;
>         a1 = (s) * (y2 - y1);
>         a2 = area - a1;
>         y.x1 = x1 + s; y.y1 = y1;
>         y.x2 = x2; y.y2 = y2;
>         y.area = a2;
>         
>         x.x1 = x1; x.y1 = y1;
>         x.x2 = x1 + s; x.y2 = y2;
>         x.area = a1;
>     }
>     else
>     {
>         if (s < 0) s += y2 - y1;
>         a1 = (s) * (x2 - x1);
>         a2 = area - a1;
>         y.x1 = x1; y.y1 = y1 + s;
>         y.x2 = x2; y.y2 = y2;
>         y.area = a2;
>         
>         x.x1 = x1; x.y1 = y1;
>         x.x2 = x2; x.y2 = y1 + s;
>         x.area = a1;
>     }
>     if (x.area <= y.area) *this = x, space[rear] = y;
>     else                  *this = y, space[rear] = x;
>     rear ++;
> }
> 
> void solve ()
> {
>     int i, j, p, s;
>     space[1].x1 = space[1].y1 = 0;
>     space[1].x2 = w; space[1].y2 = d;
>     space[1].area = w * d; rear = 2;
>     for (i = 1; i <= n; i ++)
>     {
>         scanf ("%d %d", &p, &s);
>         atype a = space[p];
>         for (j = p + 1; j < rear; j ++)
>         {
>             space[j - 1] = space[j];
>         }
>         space[rear - 1] = a;
>         space[rear - 1].cut (s);
>     }
>     space[0].area = -1;
>     sort (space + 1, space + rear);
>     for (i = 1; i < rear; i ++)
>     {
>         if (i > 1) printf (" ");
>         printf ("%d", space[i].area);
>     }
>     printf ("\n");
> }
> 
> int main ()
> {
>     
>     while (EOF != scanf ("%d %d %d", &n, &w, &d), (n + w + d))
>     solve ();
>     return 0;
> }
> 
> 

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator