您当前的位置: 首页 > 

先求一个导

暂无认证

  • 1浏览

    0关注

    291博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

牛客寒训营2 A(炉石的题都做不出来,只能说明炉石玩的不行)

先求一个导 发布时间:2022-02-01 10:32:36 ,浏览量:1

题目 题意: 起始有一点蓝,有n张攻击牌,消耗一点蓝造成一点伤害;m张回蓝牌,回复一点蓝。每次使用完一张牌,就会使得剩余所有攻击牌的伤害永久提升一点。比如先回了一点蓝,接下来连续攻击两次,造成伤害2 + 3 = 5.k次询问,判断能否恰好造成x点伤害。 思路: Binary Search.首先可用的攻击牌是n = min(n,m+1),否则蓝不够。伤害最少是nn,平A接回蓝接平A接回蓝;伤害最多是 n * m+n(n+1)/2回蓝全用完接平A接平A。在此区间内的都能达到,在最少序列交换两个相邻平A和回蓝就能+1,直到交换至伤害最多的nm+n(n+1)/2。可以将攻击次数a带入n,求出每个区间。可以发现大部分区间都重叠,只有少数覆盖不到。   方法一: 二分攻击次数,首先保证左端点=x即可。O(klog(x))   方法二: 进一步发现,当a>=4时,会发现上一个区间的右端点>=当前区间的左端点,也就是可以全覆盖。当b>=3时,[1,nm+n*(n+1)/2]都能覆盖。当b>T; // read(T); while(T--) { solve(); } return 0; }

// Problem: 小沙的炉石
// Contest: NowCoder
// URL: https://ac.nowcoder.com/acm/contest/23477/A
// Memory Limit: 524288 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define OldTomato ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define fir(i,a,b) for(int i=a;i= 3) 
    {
   	   if(x >= l && x = l && x >T;
   // read(T);
   while(T--)
   {
   	 solve();
   }
   return 0;
}

关注
打赏
1662037414
查看更多评论
立即登录/注册

微信扫码登录

0.0402s