恒美微站 Logo 恒美微站
  • 首页
  • 关于我们
  • 建站服务
  • 主题模板
  • 案例展示
  • 资讯中心
  • 联系我们

贪心-Fight Against Monsters

  • 首页
  • 资讯中心
  • /
  • 贪心-Fight Against Monsters

相关资讯

AI如何重塑你的日常?7大高频生活领域正在被悄悄重构(2024权威实证报告) 2026/8/2 17:55:26
企业级AI内容水印与反伪造双轨体系搭建,覆盖生成、传播、存证全链路(限首批200家机构授权方案) 2026/8/2 17:55:26
物联网设备电池优化:NBM7100A与STM32的低功耗设计实践 2026/8/2 17:55:27

最新资讯

GD32M531电机控制芯片评测:FOC外设协同与ADC采样实战
编译器分层诊断法:破解LLM推理Triton内核性能瓶颈
系统动力学与时间序列概率建模:应对复杂动态系统的组合方法
C++模板编程:从函数模板到可变参数,掌握泛型编程核心
Python科学计算实战:从环境配置到NumPy、SciPy、Pandas核心库应用
DeepSeek桌面客户端爆火背后:开源API封装与零门槛AI应用解析

今日推荐

Go语言构建企业级AI服务网关:统一管理英伟达等AI接口调用
LeetCode Hot100(51-60)算法精解与面试技巧
CRC校验实战:从模2除法到HJ212协议排错

本周热门

Nextcloud 桌面客户端:把同步交给它,你只管改文件
如何将 HTML 转成 Word 文档且格式不丢失?html-to-docx 使用教程
Anki 批量操作卡片完整指南:一次搞定上千张,不再逐张修改

本月精选

如何用DamaiHelper实现演唱会门票的智能自动化抢购:完整技术解决方案指南
第4篇:59 倍性能差距的索引瓶颈定位——一次教科书级的全表扫描调优
终极歌词批量下载神器:5分钟解决离线音乐库歌词同步难题

贪心-Fight Against Monsters

发布时间:2026/8/27 2:29:35
贪心-Fight Against Monsters Fight Against Monsters题意一个英雄与多个怪兽对战怪兽先手每次对其英雄造成的伤害为目前存活的怪兽的伤害总和而英雄对同一只怪兽造成的伤害第一回合为1第二回合为2第三回合为3以此类推当怪兽血量小于等于0时该怪兽死亡问英雄打败怪兽后最低消耗多少血量。It is my great honour to introduce myself to you here. My name is Aloysius Benjy Cobweb Dartagnan Egbert Felix Gaspar Humbert Ignatius Jayden Kasper Leroy Maximilian. As a storyteller, today I decide to tell you and others a story about the hero Huriyyah, and the monsters.Once upon a time, citizens in the city were suffering from nnn powerful monsters. They ate small children who went out alone and even killed innocent persons. Before the hero appeared, the apprehension had overwhelmed the people for several decades. For the good of these unfortunate citizens, Huriyyah set off to the forest which was the main lair of monsters and fought with nnn fierce and cruel monsters. The health point of the iii-th monster was HPiHP_iHPi​, and its attack value was ATKiATK_iATKi​.They fought in a cave through a turn-based battle. During each second, the hero Huriyyah was attacked by monsters at first, and the damage was the sum of attack values of all alive monsters. Then he selected a monster and attacked it. The monster would suffer the damage of kkk (its health point would decrease by kkk) which was the times of attacks it had been came under. That is to say, for each monster, the damage of the first time that Huriyyah attacked it was 111, and the damage of Huriyyah’s second attack to this monster was 222, the third time to this monster was 333, and so on. If at some time, the health point of a monster was less than or equal to zero, it died. The hero won if all monsters were killed.Now, my smart audience, can you calculate the minimum amount of total damages our hero should suffer before he won the battle?InputThe input contains several test cases, and the first line is a positive integer TTT indicating the number of test cases which is up to 10310^3103.For each test case, the first line contains an integers n(1≤n≤105)n (1 \le n \le 10^5)n(1≤n≤105) which is the number of monsters. The iii-th line of the following nnn lines contains two integers HPiHP_iHPi​ and ATKi(1≤HPi,ATKi≤105)ATK_i (1 \le HP_i, ATK_i \le 10^5)ATKi​(1≤HPi​,ATKi​≤105) which describe a monster.We guarantee that the sum of nnn in all test cases is up to 10610^6106.OutputFor each test case, output a line containing Case #x: y, where xxx is the test case number starting from 111, and yyy is the minimum amount of total damages the hero should suffer.输出时每行末尾的多余空格不影响答案正确性样例输入231 12 23 333 12 21 3样例输出Case #1: 19Case #2: 14思路贪心计算每只怪兽需要攻击的次数用攻击的次数/该怪兽的攻击力来评价攻击该怪兽的性价比按从小到大顺序排列即需要攻击的次数越小该怪兽的攻击力越高该怪兽越先被击杀由于小数可能存在精度问题可以将分母乘上去·。 #includestdio.h #includecstring #includemath.h #define maxn 100010 #includealgorithm using namespace std; struct node{ long long hea;//血量 long long att;//攻击力 long long tem;//打败该怪兽需要攻击的次数 }list[maxn]; bool cmp(const node x,const node y) { return x.tem*y.atty.tem*x.att; } int main() { long long t,n,i,cout,sum,at,coutt,s,d; scanf(%lld,t);coutt0; while(t--) { scanf(%lld,n); for(at0,i1;in;i) { scanf(%lld%lld,list[i].hea,list[i].att); atlist[i].att; dlist[i].hea; s1;list[i].tem0; while(d0) { d-s; s; list[i].tem; } } sort(list1,list1n,cmp); for(sum0,i1;in;i) { cout1; while(list[i].hea0){ sumat; list[i].hea-cout; cout; } at-list[i].att; } coutt; printf(Case #%lld: %lld\n,coutt,sum); } return 0; }

关于恒美微站

恒美微站专注于为个体商户、工作室提供极简自助建站服务,让每个人都能轻松拥有专业网站。

快速链接

  • 关于我们
  • 建站服务
  • 主题模板
  • 案例展示
  • 资讯中心

服务项目

  • 可视化建站
  • 拖拽编辑
  • 主题定制
  • SEO 优化
  • 网站托管

联系方式

  • 📍 地址:北京市朝阳区建国路 88 号
  • 📞 电话:400-888-8888
  • ✉️ 邮箱:info@hmyw.cn
  • 🕐 时间:周一至周日 9:00-18:00

© 2024 恒美微站 hmyw.cn 版权所有 | 京 ICP 备 12345678 号