A - 3D Printed Statues(周赛3)

You have a single 3D printer, and would like to use it to produce n

statues. However, printing the statues one by one on the 3D printer takes a long time, so it may be more time-efficient to first use the 3D printer to print a new printer. That new printer may then in turn be used to print statues or even more printers. Print jobs take a full day, and every day you can choose for each printer in your possession to have it print a statue, or to have it 3D print a new printer (which becomes available for use the next day).

What is the minimum possible number of days needed to print at least n

statues?
Input

The input contains a single integer n
(1≤n≤10000

), the number of statues you need to print.
Output

Output a single integer, the minimum number of days needed to print at least n

statues.
Sample Input 1
1
Sample Output 1
1

Sample Input 2
5
Sample Output 2
4

这道题想了半天想歪了,以为用啥二分啊我分分分了半天,还是没出来,后来列了从1到17个雕塑要用的时间就灵光一现发现规律了啊啊啊啊,激动地打下了代码,小心地交了上去,侥幸地过了!!!!!!打完这题我就弃赛了哈哈。
思路就是前几天肯定都是成倍成倍地复制打印机啊,最后一天打塑像。就是x=1*2……*2,当x大于等于我们要的雕塑时,就可以开始打印啦。所以就是打印打印机的这么多天加上一天打雕塑的时间。完美!

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,l,x=1;
    scanf("%d",&n);
     if(n==1){
        printf("1\n");
        return 0;
    }
    for(int i=1;i<n;i++){
        x=x*2;
        if(x>=n){
            printf("%d\n",i+1);
            return 0;
        }
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值