POJ 1017 Packets
来源:互联网 发布:有毒网络剧有第二季吗 编辑:程序博客网 时间:2024/06/05 03:12
题目链接:http://poj.org/problem?id=1017
题目描述:
给定6个数,表示是1*1,2*2....6*6的正方形的个数,现将这些正方形放在6*6的正方形中,问最少需要多少个6*6的正方形。
纯模拟即可解。由大到小考虑即可。
#include<cstdio>#include<iostream>using namespace std ;int a[6] ;void cal(){int res = 0 ;int num1, num2 ;//6res += a[5] ;//5res += a[4] ;num1 = a[4]*11 ;//4res += a[3] ;num2 = 5*a[3] ;//3if( a[2] % 4 == 0 ){res += a[2] / 4 ;} else{res += a[2] / 4 + 1 ;switch(a[2]%4){case 1 :num2 += 5 ;num1 += 7 ;break ;case 2:num2 += 3 ;num1 += 6 ;break ;case 3:num2 += 1 ;num1 += 5 ;break ;}}//2if( num2 >= a[1] ){num2 -= a[1] ;num1 += num2*4 ;} else{a[1] -= num2 ;if( a[1] % 9 == 0 ){res += a[1] / 9 ;}else{res += a[1] / 9 + 1 ;num1 += (9-a[1]%9)*4 ;}}//1if( num1 < a[0]){a[0] -= num1 ;if( a[0] % 36 == 0 ){res += a[0] / 36 ;}else{res += a[0] / 36 + 1 ;}}cout << res << endl ;}int main(){freopen("1234.in","r",stdin) ;while( 1 ){int num = 0 ;for( int i = 0; i < 6; i++ ){scanf("%d",&a[i]) ;if( a[i] == 0 )num++ ;}if( num == 6 ) break ;cal() ;}return 0 ;}
0 0
- poj 1017 Packets【贪心】
- POJ 1017 Packets(贪心)
- poj 1017 Packets
- POJ 1017 Packets
- POJ 1017 Packets
- poj 1017 Packets(贪心)
- poj 1017 Packets
- poj 1017 Packets
- POJ 1017 Packets
- POJ 1017 Packets
- POJ 1017 Packets
- poj 1017 Packets
- POJ-1017-Packets
- poj 1017 Packets ( 贪心 )
- POJ 1017Packets(贪心)
- POJ 1017 Packets
- poj 1017 Packets
- [POJ][1017]Packets
- 配置probe来监控tomcat
- 接口
- 第八周项目四——个人所得税计算器
- 在linux终端删除系统应用APK
- Android 使用HttpUrlConnection处理请求
- POJ 1017 Packets
- 定期存款利息计算器
- 第八周项目二:多分段函数求值(1)
- sbobet เล่นได้ทุกที่ทุกเวลา
- android-插件化开发研究
- nginx入门学习—— 在已安装好的nginx上添加sticky模块(二)
- 第8周项目6本月有几天
- OnEraseBkGnd的使用
- poj2533--Longest Ordered Subsequence(dp:最长上升子序列)