ACM/ICPC 之 模拟 (HNUOJ 13391-换瓶模拟)

时间:2023-02-08 16:03:57

  题意:汽水瓶有三个部分cap+plastic bottle+ label(瓶盖-瓶身-瓶底),给出数据:n为原瓶数,x,y,z为这三个部分可以用相应的数字换取新瓶子,求最大总瓶数。

  模拟(暴力)

  

 //汽水瓶有三个部分-cap+plastic bottle+ label
//n为原瓶数
//x,y,z为这三个部分可以用相应的数字换取新瓶子,求最大总瓶数
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std; int t[]; //当前三部分数量(按换瓶基数-调整顺序)
int c[]; //三部分换瓶基数 int main()
{
int T,n;
scanf("%d",&T); while(T--)
{
int b = ;
scanf("%d%d%d%d",&n,&c[],&c[],&c[]);
b = t[] = t[] = t[] = n; sort(c,c+); //排序(偷懒啦= =) int res; //可换瓶数量
while(t[]/c[] || t[]/c[] || t[]/c[])
{
if(t[]/c[])
{
b += res = t[]/c[];
t[] = t[]%c[]+res;
t[] += res;
t[] += res;
}
if(t[]/c[])
{
b += res = t[]/c[];
t[] = t[]%c[]+res;
t[] += res;
t[] += res;
}
if(t[]/c[])
{
b += res = t[]/c[];
t[] = t[]%c[]+res;
t[] += res;
t[] += res;
}
}
printf("%d\n",b);
} return ;
}