poj1017
来源:互联网 发布:ubuntu suspend 编辑:程序博客网 时间:2024/05/16 19:23
#include<iostream>
#define SIZE 50000
using namespace std;
int newpacket(int a, int b, int c, int d,int e,int f){
int ans = 0;
int one = 0;
int two = 0;
ans += f;//装6*6的
ans += e;//装5*5的
one += e*11; //1*1还剩下的
ans += d;//装4*4的
two += d*5;//2*2还剩下的
int three = c/4;//装3*3的
int ttemp = c%4;//不满的
ans += ((ttemp==0)?three:(three+1)) ;
// 装了3个3*3就还可以装1个2*2 装了2个3*3就还可以装3个2*2 装了1个3*3就还可以装5个2*2
int ttwo = ((ttemp==0)? 0: (2*( 4 -ttemp)-1));//装了3剩下可装2的
two += ttwo;
//装了3个3*3就还可以装5个1*1 装了2个3*3就还可以装6个1*1 装了1个3*3就还可以装7个1*1
int tone = ((ttemp==0)? 0: (8 - ttemp));//装了3剩下可装2还剩下的可装1的
one += tone;
int tempb = 0;
if(b > two){ //装2*2
tempb = b -two;
int mytempb = tempb%9;
ans += ((mytempb==0)? (tempb/9):(tempb/9 +1));
//剩下每一个2*2的空位可以有4个1*1
one += ((mytempb==0)? 0: 4*(9-mytempb));
} else{
tempb = two - b;
one += 4* tempb;
}
int tempa = 0;
if(a > one){
tempa = a -one;
int mytempa = tempa%36;
ans += ((mytempa==0)?(tempa/36):(tempa/36 +1));
}else{
}
return ans;
}
int main(void){
int a,b,c,d,e,f;
while(cin>>a>>b>>c>>d>>e>>f){
if(a==0 && b==0 && c==0&&d==0&&e==0&&f==0)
return 0;
// cout<<packet(a,b,c,d,e,f)<<endl;
cout<<newpacket(a,b,c,d,e,f)<<endl;
}
// system("pause");
return 0;
}
#define SIZE 50000
using namespace std;
int newpacket(int a, int b, int c, int d,int e,int f){
int ans = 0;
int one = 0;
int two = 0;
ans += f;//装6*6的
ans += e;//装5*5的
one += e*11; //1*1还剩下的
ans += d;//装4*4的
two += d*5;//2*2还剩下的
int three = c/4;//装3*3的
int ttemp = c%4;//不满的
ans += ((ttemp==0)?three:(three+1)) ;
// 装了3个3*3就还可以装1个2*2 装了2个3*3就还可以装3个2*2 装了1个3*3就还可以装5个2*2
int ttwo = ((ttemp==0)? 0: (2*( 4 -ttemp)-1));//装了3剩下可装2的
two += ttwo;
//装了3个3*3就还可以装5个1*1 装了2个3*3就还可以装6个1*1 装了1个3*3就还可以装7个1*1
int tone = ((ttemp==0)? 0: (8 - ttemp));//装了3剩下可装2还剩下的可装1的
one += tone;
int tempb = 0;
if(b > two){ //装2*2
tempb = b -two;
int mytempb = tempb%9;
ans += ((mytempb==0)? (tempb/9):(tempb/9 +1));
//剩下每一个2*2的空位可以有4个1*1
one += ((mytempb==0)? 0: 4*(9-mytempb));
} else{
tempb = two - b;
one += 4* tempb;
}
int tempa = 0;
if(a > one){
tempa = a -one;
int mytempa = tempa%36;
ans += ((mytempa==0)?(tempa/36):(tempa/36 +1));
}else{
}
return ans;
}
int main(void){
int a,b,c,d,e,f;
while(cin>>a>>b>>c>>d>>e>>f){
if(a==0 && b==0 && c==0&&d==0&&e==0&&f==0)
return 0;
// cout<<packet(a,b,c,d,e,f)<<endl;
cout<<newpacket(a,b,c,d,e,f)<<endl;
}
// system("pause");
return 0;
}
0 0
- POJ1017
- poj1017
- poj1017
- poj1017
- poj1017
- poj1017
- poj1017
- poj1017
- poj1017
- poj1017
- POJ1017
- poj1017
- poj1017
- poj1017
- poj1017
- poj1017 packets
- POJ1017-Packets
- 贪心--poj1017
- 快速排序算法详解与实现
- poj 1949——Chores
- 总有一天你将破蛹而出
- 关于谢灵抄袭案媒体采访的声明
- 验证表单内容为空
- poj1017
- 习题3-10 盒子 UVa1587
- Django:错误集合
- Andrew ng清华报告
- 2014-7 Andrew Ng 自动化所报告
- 要想进步必须得不停得学习
- Path Sum
- 重定向的一些小记录,个人粗略的不成熟的理解
- Topic Model(主题模型)交流