CodeForces 487A Fight the Monster
来源:互联网 发布:知乎 颗粒板 编辑:程序博客网 时间:2024/05/20 17:07
题意:
打怪兽游戏 我的血量hpy、攻击atky、防御defy 怪兽的血量hpm、攻击atkm、防御defm 每秒我损失血量max(0,atkm-defy) 怪兽损失血量max(0,atky-defm) 如果某一时刻我活着怪兽死了 算我胜利 购买1点hp花费h购买1点atk花费a购买1点def花费d 问最少多少花费能保证胜利 题目中数字均小于100
思路:
数字很小想到暴力枚举就好 不过这题要仔细讨论枚举上界
易知最多用100s就能杀死怪兽 (在能杀死的情况下)
对于hp 怪兽对我造成伤害最大为100 能持续100s 因此上界应该是10000
对于atk 怪兽hp最多100 防御最大100 为了保证在1s内杀死怪兽 上界应该是200
对于def 怪兽攻击最大100 因此上界100足矣
讨论出来后发现3个一起枚举会TLE 那么采用枚举2个计算另一个的方式
代码:
#include<cstdio>#include<iostream>#include<cstring>#include<string>#include<algorithm>#include<map>#include<set>#include<vector>#include<queue>#include<cstdlib>#include<ctime>#include<cmath>using namespace std;typedef long long LL;#define N 6010int hy, ay, dy;int hm, am, dm;int h, a, d;int ans = 100000000;int main() { scanf("%d%d%d%d%d%d%d%d%d", &hy, &ay, &dy, &hm, &am, &dm, &h, &a, &d); for (int i = 0; i <= 200; i++) { for (int j = 0; j <= 100; j++) { int atk = ay + i; int def = dy + j; if (atk > dm) { if (def >= am) ans = min(ans, i * a + j * d); else { int t = hm / (atk - dm); if (t * (atk - dm) < hm) t++; int should = (am - def) * t + 1; if (should > hy) should -= hy; else should = 0; ans = min(ans, i * a + j * d + should * h); } } } } printf("%d\n", ans); return 0;}
0 0
- codeforces 487A Fight the Monster
- 【Codeforces】 487A Fight the Monster
- CodeForces 487A Fight the Monster
- codeforces #487A# Fight the Monster(枚举)
- Codeforces 487A Fight the Monster(暴力)
- Codeforces 487A Fight the Monster
- codeforces 487 A Fight the Monster 暴力枚举
- Codeforces Round #278 (Div. 1) A. Fight the Monster( 暴力)
- CF488C Fight the Monster
- Codeforces Round #278 (Div. 2) 488C.Fight the Monster
- Codeforces 488 C. Fight the Monster(模拟)
- Codeforces Round #278 (Div. 2) C. Fight the Monster(暴力)
- codeforces 488C Fight the Monster(枚举)
- Codeforces 488C Fight the Monster【二分+枚举】
- CodeForces 488 C.Fight the Monster(枚举)
- CodeForces 787A The Monster
- CF_487A Fight the Monster(二分)
- Fight the Monster题解报告
- 关于<base>标签影响锚点的问题
- 对div块的拖动放大缩小
- TCP/IP详解(协议)笔记——ARP和RARP
- 中国象棋将帅问题
- 10.10系统下 Xcode出现的 一些问题
- CodeForces 487A Fight the Monster
- 基础动画详解
- 上海钢结构设计招聘全面分析
- C语快速入门教程(2)
- ubutun 14.04安装配置vsftpd
- thinkpad e431 装完ubuntu14.04之后无线网卡么有启动
- swift入门基础知识1基本数据类型
- USB bulk设备中的CBW和CSW
- CocoaPods安装和使用教程