题意:
ABCDE五个数,告诉你每轮各自的变化,问什么时候总和能超过M
解法:
说得胡里花哨,其实就是每轮总和倍增。
//Time:9ms
//Memory:0KB
///Length;879B
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
long long int a, b, c, d, e, m;
int main()
{
int cas, t=0;
scanf("%d", &cas);
while (cas--)
{
scanf("%lld%lld%lld%lld%lld%lld",&a,&b,&c,&d,&e,&m);
long long tmp=a+b+c+d+e;
printf("Case #%d: ", ++t);
long long tt=1;
bool flag=0;
for (int n=0; n<31; n++)
{
if (tt*tmp>=m)
{
printf("%d\n", n);
flag=1;
break;
}
tt<<=1;
}
if (!flag) printf("-1\n");
}
return 0;
}