解题思路:
注意事项:
参考代码:
用到数学函数ceil求较大整值
#include<stdio.h>
#include<math.h>
#include<iostream>
using namespace std;
int datas[7];
int main()
{
int thr[] = { 0,5,3,1 },k=0,a[100];//thr[]为2*2在3*3所在包装箱里数量分别为4,3,2,1时可以摆放的数量
while (true)
{
int total = 0;
for (int i = 1; i <= 6; i++)
cin >> datas[i];
if (datas[1] == 0&& datas[2] == 0 && datas[3] == 0 && datas[4] == 0 && datas[5] == 0 && datas[6] == 0)
break;
total += datas[6] + datas[5] + datas[4] + (int)ceil(datas[3] / 4.0);
int last2 = datas[4] * 5 + thr[datas[3] % 4];
if (datas[2] > last2)
total += (int)ceil((datas[2] - last2) / 9.0);
int last1 = 36 * (total - datas[6]) - datas[5] * 25 - datas[4] * 16 - datas[3] * 9 - datas[2] * 4;
if (datas[1] > last1)
total += (int)ceil((datas[1] - last1) / 36.0);
a[k] = total;
k++;
}
for (int j = 0; j < k; j++)
cout << a[j] << endl;
}
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题6.4 (C语言代码)浏览:643 |
矩阵乘法 (C++代码)浏览:1454 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:377 |
C语言程序设计教程(第三版)课后习题10.3 (C语言代码)浏览:1909 |
小九九 (C语言描述,不看要求真坑爹)浏览:984 |
妹子杀手的故事 (C语言代码)浏览:1045 |
输入输出格式练习 (C语言代码)浏览:842 |
C语言程序设计教程(第三版)课后习题12.1 (C语言代码)浏览:642 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:463 |
C二级辅导-统计字符 (C语言代码)浏览:627 |