1017.cpp

来自「非常好的C++学习源码,里面包括各种算法的实现,二叉的的前中后序遍历等」· C++ 代码 · 共 73 行

CPP
73
字号
#include<iostream>
using namespace std;
int main()
{
	int a1,a2,a3,a4,a5,a6,total,b2,b1,count2[4]={0,5,3,1},count1[4]={0,7,6,5};
	while (cin>>a1>>a2>>a3>>a4>>a5>>a6)
	{
		total=0;
		b2=0;
		b1=0;
		if ((a1==0)&&(a2==0)&&(a3==0)&&(a4==0)&&(a5==0)&&(a6==0))
			break;
		else 
		{
			total=a6+a5+a4+a3/4;
			if (a3%4)
				total++;
			b2=a2-5*a4;
			if (b2<=0)
			{
				if ((a3%4)==0)
					b1=a1-a5*11-(20*a4-4*a2);
				else
					b1=a1-a5*11-(20*a4-4*a2)-(36-(a3%4)*9);
				if(b1>0)
				{
					total+=b1/36;
					if (b1%36)
						total++;
				}
			}
			if (b2>0)
			{
				b2=b2-count2[a3%4];
				if (b2>0)
				{
					total+=b2/9;
					if (b2%9)
						total++;
					b1=a1-count1[a3%4]-a5*11;
					if (b1>0)
					{
						b1=b1-(36-4*(b2%9));
						if (b1>0)
						{
							total+=b1/36;
							if (b1%36)
								total++;
						}
					}
				}
				if (b2<=0)
				{
					b1=a1-a5*11-(36-(a3%4)*9)-(count2[a3%4]+b2)*4;
					if (b1>0)
					{
						total+=b1/36;
						if (b1%36)
							total++;
					}
				}
			}
			printf("%d\n",total);
		}
	}
	return 0;
}
	
	
	
	
	

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?