1685.cpp
来自「这是哈尔滨工业大学acmOJ的源代码」· C++ 代码 · 共 45 行
CPP
45 行
/* This Code is Submitted by wywcgs for Problem 1685 on 2005-03-24 at 07:12:02 */
#include <stdio.h>
int main()
{
int maxWid, totalLen, totalWid, recLen, recWid;
int curLen, curWid;
while(scanf("%d", &maxWid) == 1){
if(maxWid == 0){
return 0;
}else{
totalLen = 0;
totalWid = 0;
curLen = 0;
curWid = 0;
while(scanf("%d %d", &recWid, &recLen) == 2){
if((recLen == -1) && (recWid == -1)){
if(totalWid < curWid){
totalWid = curWid;
}
totalLen += curLen;
break;
}else{
if(recWid + curWid <= maxWid){
curWid += recWid;
if(curLen < recLen){
curLen = recLen;
}
}else{
if(totalWid < curWid){
totalWid = curWid;
}
curWid = recWid;
totalLen += curLen;
curLen = recLen;
}
}
}
printf("%d x %d\n", totalWid, totalLen);
}
}
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?