解题思路:
先分析,在贪心。
参考代码:
#include<bits/stdc++.h> using namespace std; int datas[7]; bool ends() { for (int i = 1; i <= 6; i++) if (datas[i] != 0) return false; return true; } int main() { int thr[] = { 0,5,3,1 }; while (true) { int total = 0; for (int i = 1; i <= 6; i++) cin >> datas[i]; if (ends()) return 0; 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); cout << total << endl; } }
0.0分
1 人评分
C语言程序设计教程(第三版)课后习题7.5 (C语言代码)浏览:605 |
C二级辅导-分段函数 (C语言代码)浏览:558 |
C二级辅导-统计字符 (C语言代码)浏览:533 |
C语言训练-求素数问题 (C语言代码)浏览:720 |
人见人爱A+B (C语言代码)浏览:626 |
2003年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:603 |
wu-理财计划 (C++代码)浏览:831 |
IP判断 (C语言代码)浏览:762 |
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)from DQM浏览:653 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:901 |