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 2016213435 at 2019-04-14 11:42:00 on Problem 1017
#include <stdio.h>
#include <string.h>

int box[7];
int main(){
memset(box, 0, sizeof(box));
while (scanf("%d%d%d%d%d%d", &box[1], &box[2], &box[3], &box[4], &box[5], &box[6])){
if(box[1] == 0 && box[2] == 0 && box[3] == 0 && box[4] == 0 && box[5] == 0 && box[6] == 0) break;
int cnt = 0;
cnt += box[6];
cnt += box[5];
box[1] -= box[5] * 11;
cnt += box[4];
int box3Num = box[3] % 4 == 0 ? box[3] / 4 : box[3] / 4 + 1;
cnt += box3Num;
int remain3space = box3Num * 4 - box[3]; //剩余可装3 * 3的数量
int remain4space = box[4] * 5; //剩余可装2 * 2的数量

box[2] -= remain4space;
if(box[2] < 0){
remain4space = -box[2] * 4;
if(remain4space > 0){
box[1] -= remain4space;
}
}

if(remain3space == 3){
box[2] -= 5;
if(box[2] < 0){
remain3space = -box[2] * 4;
if(remain3space > 0){
box[1] -= remain3space;
}
}
box[1] -= 7;

}else if(remain3space == 2){
box[2] -= 3;
if(box[2] < 0){
remain3space = -box[2] * 4;
if(remain3space > 0){
box[1] -= remain3space;
}
}
box[1] -= 6;

} else if(remain3space == 1){
box[2] --;
if(box[2] < 0){
remain3space = -box[2] * 4;
if(remain3space > 0){
box[1] -= remain3space;
}
}
box[1] -= 5;

}

if(box[2] > 0){
int box2num = box[2] % 9 == 0 ? box[2] / 9 : box[2] / 9 + 1;
cnt += box2num;
int remain2space = 9 * box2num - box[2];
remain2space *= 4;
box[1] -= remain2space;
}

if(box[1] > 0){
int box1num = box[1] % 36 == 0 ? box[1] / 36 : box[1] / 36 + 1;
cnt += box1num;
}

printf("%d\n", cnt);
}
}

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