码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • The 2022 ICPC Asia Xian Regional Contest--C. Clone Ranran


    Ranran needs to prepare a contest! A contest is made of c problems, and Ranran can do one of the following two things:

    • Clone himself in a minutes. That is, after a minutes, there will be one more Ranran.
    • Prepare a problem in b minutes. That is, after b minutes, there will be one more problem.

    Note that a cloned Ranran can also do the two things above. A Ranran cannot do the two things at the same time.

    Ranran wants to prepare the contest as fast as possible. But he is very lazy, so he asks you to find the minimum number of minutes to prepare the contest.

    You need to answer T queries independently.

    Input

    The first line contains an integer T (1≤T≤10^5).

    Each of the next T lines contains three integers aa, bb and cc (1≤a,b,c≤109), representing a query.

    Output

    For each test case, output a line with a single integer representing the answer.

    Example

    input

    1. 5
    2. 1 1 1
    3. 2 3 3
    4. 9 9 9
    5. 3 26 47
    6. 1064 822 1048576

    output

    1. 1
    2. 7
    3. 45
    4. 44
    5. 21860

    题意:主人公初始有0个题目,可以花a分钟克隆自己,可以花b分钟使每个自己创造1个题目,问创造c个题目的最小耗时。

    解析:可以发现,克隆自己是2的幂次,可以推出,如果需要克隆N次,那么先克隆N次,最后再操作2肯定是最合理的,因此我们可以枚举克隆的次数,因为是指数,所以最多才31次(因为c最大10的9次)

    1. #include
    2. #include
    3. using namespace std;
    4. typedef long long ll;
    5. void solve()
    6. {
    7. ll a,b,c,r=1,minn=1e15;//最小值初始化要大一点
    8. scanf("%lld%lld%lld",&a,&b,&c);
    9. for(int i=0;i<32;i++)//克隆i次
    10. {
    11. minn=min(minn,i*a+((c-1)/r+1)*b);//更新答案
    12. r*=2;
    13. }
    14. printf("%lld\n",minn);
    15. }
    16. int main()
    17. {
    18. int t;
    19. scanf("%d",&t);
    20. while(t--) solve();
    21. return 0;
    22. }
  • 相关阅读:
    计算机网络原理 谢希仁(第8版)第三章习题答案
    达梦数据库sql中with语句的使用
    【广州华锐互动】3D景区实景导航,让旅行加更加舒适轻松
    Linux巡检脚本
    HelpLook全新升级!定制AI问答机器人,企业内容中心焕新
    《WEB前端框架开发技术》HTML5响应式旅游景区网站设计与实现——榆林子州HTML+CSS+JavaScript...
    刷新页面,数据丢失
    CI/CD 工具和技术:释放 DevOps 的力量
    【Python基础】高级数据类型:初识 “列表” || 列表的增删改查 || del关键字 || 列表的定义
    Vue(二)——基本操作
  • 原文地址:https://blog.csdn.net/qq_63739337/article/details/128077888
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号