zoukankan      html  css  js  c++  java
  • PKU3327

    WA了N次...
    #include<string.h>
    #include 
    <stdio.h>

    struct Rect
    {
        
    int w, d;
    }
    ;

    int c, w, d, cnt, p, s;
    Rect rect[
    110];
    int area[110];

    void cut()
    {
        
    int hw=rect[p].w, hd=rect[p].d ;
        s
    %=(2*(hw+hd));
        rect[cnt]
    =rect[p];
        
    if(s>0 && s<hw)
        
    {
            rect[p].w
    =s,rect[p].d=hd;
            rect[cnt].w
    =hw-rect[p].w;
        }

        
    if(s>hw && s<hw+hd)
        
    {
            rect[p].w
    =hw,rect[p].d=s-hw;
            rect[cnt].d
    =hd-rect[p].d;
        }

        
    if(s>hw+hd && s<2*hw+hd)
        
    {
            rect[p].w
    =s-hw-hd,rect[p].d=hd;
            rect[cnt].w
    =hw-rect[p].w;
        }

        
    if(s>2*hw+hd && s<2*hw+2*hd)
        
    {
            rect[p].w
    =hw,rect[p].d=s-2*hw-hd;
            rect[cnt].d
    =hd-rect[p].d;
        }

        
    //
        if(rect[p].w * rect[p].d > rect[cnt].d * rect[cnt].w)
        
    {
            Rect hr
    =rect[p];
            rect[p]
    =rect[cnt];
            rect[cnt]
    =hr;
        }
          Rect hr1=rect[p];
          int i;
          for(i=p;i<cnt-1;i++)
              rect[i]=rect[i+1];
          rect[cnt-1]=hr1;

    }


    int main()
    {
        
    while(scanf("%d%d%d"&c, &w, &d)==3)
        
    {
            
            
            
    if(c==0 && w==0 && d==0)break;
            cnt
    =1;
            
    int i, j; 
            
    for(i=0;i<110;i++)
                rect[i].d
    =rect[i].w=area[i]=0;

            rect[
    1].w=w,rect[1].d=d;

            
    for(i=1;i<=c;i++)
            
    {
                scanf(
    "%d%d",&p,&s);
                cnt
    ++;
                cut();
            }

            
    for(i=1;i<=c+1;i++)
            
    {
            
    //    printf("%d :  %d , %d  \n",i,rect[i].w,rect[i].d);
                int harea=rect[i].w * rect[i].d;
                
    for(j=i;j>=1;j--)
                
    {
                    area[j]
    =area[j-1];
                    
    if(harea>area[j])
                    
    {
                        area[j]
    =harea;
                        
    break;
                    }

                }

            }


            
    for(i=1;i<=c+1;i++)
            
    {
                
    if(i!=1)printf(" ");
                printf(
    "%d",area[i]);
            }

            printf(
    "\n");
        }

        
    return 0;
    }

  • 相关阅读:
    MySQL字段数据全部查出【只保留中文、英文、数字、空格的词表】
    MySQL查看当前运行的事务和执行的账户
    【转】【MySQL报错】ERROR 1558 (HY000): Column count of mysql.user is wrong. Expected 43, found 39.
    【转】mysqldump的锁表的问题
    mysql 通过echo的方式写入数据库 中文乱码解决方案
    Python3.5爬取豆瓣电视剧数据并且同步到mysql中
    Python3.5爬取cbooo.cn数据并且同步到mysql中
    【转&参考】MySQL利用frm和ibd文件进行数据恢复
    [算法]从一道题引出variable-precision SWAR算法
    [转]nginx负载均衡的五种算法
  • 原文地址:https://www.cnblogs.com/SQL/p/913090.html
Copyright © 2011-2022 走看看