2016年中南大学校赛镜像赛(校外队伍)

1720 Problem A How to Get 2^n

1721 Problem B 皇家火枪手

Description
CLASH ROYAL是个有趣的游戏,
Johnson最近也是被它深深的迷上了。
火枪手是Johnson最喜欢用的一张卡,可能是感觉火枪打人有种爆头的快感把233
今天Johnson运气貌似特别好,对面选手游戏过程中掉线了
机不可失,Johnson准备派遣自己引以为豪的火枪大军击败对面的守卫塔
此时守卫塔还有m点血量,一个火枪手的攻击力为a点伤害每秒,但是守卫塔同样能够攻击火枪手,
我们假定守卫塔的攻击力正好可以2秒钟打死一个火枪手,那么这个被攻击的火枪手在死前可以对塔造成2*a点的伤害
现在离游戏结束只剩下k秒的时间了,Johnson此刻最少同时要派出多少个火枪手能在游戏结束前干掉对面(我们假定可以一次性派出无数个火枪手,不受圣水的限制)

Input
第一行输出一个T,表示有T组数据
每组数据输入三个正整数 m , a , k (0< m,a<=10^8 , 0< k <=100)

Output
每组数据输出一个整数表示最少一次要派出多少个火枪手

Sample Input
2
3 1 1
4 2 3
Sample Output
3
1

#include <cstdio>
#include <cmath>
using namespace std;

typedef long long LL;
int t, ans;
double m, a, k1;

int main() {
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
#endif
  scanf("%d", &t);
  while (t--) {
    scanf("%lf%lf%lf", &m, &a, &k1);
    ans = 0x3f3f3f3f;
    for (double k = 1; k <= k1; ++k) {
      int temp;
      if ((int)k & 1) {
        temp = ceil((m / a + (k - 1) / 4 * (k - 1)) / k);
      } else {
        temp = ceil((m / a + k / 4 * k - k / 2) / k);
      }
      if (ans > temp) ans = temp;
    }
    printf("%d\n", ans);
  }
  return 0;
}

1722 Problem C Race

Description
Johnson and Bob are crazy motorcycle collecting enthusiasts. In order to prove their own motorcycles is the best, they issued a challenge to each other. Johnson wants to win the challenge.As a good friend of Johnson’s, you need to give advice to Johnson. Johnson and Bob each can select their best n motorcycles. And each motorcycle has a value v. There are n matches in total. Any motorcycle can be chosen optionally to participate in the match(but each motorcycle can only participate once). Each time the motorcycle with high value will win. Johnson gets the order of Bob’s motorcycles in advance. Can you help Johnson arrange the competition order of motorcycles in order to win the most of the matches?

Input
First line input an integer T(mean there are T cases)
In each case , first line input an integer n (mean there are n motorcycles) (0 < n<=10000)
Next line input n integers (mean the value of Johnson’s n motorcycles)
Next line n integers (mean the value of Bob’s n motorcycles )

Output
Every case output an integer mean the most match can win.

Sample Input
1
5
6 4 5 1 3
8 9 3 4 7
Sample Output
2

#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

typedef long long LL;
const int SIZE = 1e5 + 10;
LL t, n, joh[SIZE], bob[SIZE];

int main() {
  scanf("%lld", &t);
  while (t--) {
    scanf("%lld", &n);
    for (int i = 0; i < n; ++i) {
      scanf("%lld", &joh[i]);
    }
    for (int i = 0; i < n; ++i) {
      scanf("%lld", &bob[i]);
    }
    sort(joh, joh + n);
    sort(bob, bob + n);
    int ans = 0, i = n - 1, j = n - 1;
    while (i >= 0 && j >= 0) {
      if (joh[i] > bob[j]) {
        ++ans;
        --i;
        --j;
      } else {
        --j;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}

1723 Problem D 想打架吗?算我一个!所有人,都过来!

Description
现在《炉石传说》这款卡牌游戏已经风靡全球。2015年加入环境的“黑石山的火焰”扩展带来了一个新套牌的核心卡片“恐怖的奴隶主”,而这套统治游戏的套牌叫做“奴隶战”。“恐怖的奴隶主”的登场音效“想打架吗?算我一个!”一定在所有这个时代的《炉石传说》玩家心里留下来难以磨灭的印象。
“恐怖的奴隶主”是一个有3点生命值的生物,当其在场上受到非致命伤害时(如3点生命值的奴隶主受到1点或2点伤害时,或者2点生命值的奴隶主受到1点伤害时)会召唤一个新的3点生命值的“恐怖的奴隶主”,受到致命伤害(伤害大于等于现有生命值)时则会直接死去。另外一类卡片可以使全部生物造成1点伤害(降低1点生命),被称为“旋风斩效果”。因此“恐怖的奴隶主”,在场上经过多次“旋风斩效果”就可能由一个变成很多个,同时发出那个令人恐惧的声音“所有人,都过来!”。
另一方面,《炉石传说》规定,场上最多存在7个生物,这极大地限制了“恐怖的奴隶主”“越生越多”。当一次“旋风斩效果”发生时,优先处理受到非致命伤害的“恐怖的奴隶主”,召唤新的“恐怖的奴隶主”,直到生物数量达到7个不再继续召唤新的“恐怖的奴隶主”,然后清除掉生命值降为0或0以下的“恐怖奴隶主”。如场上有7个生命值为1的“恐怖的奴隶主”,则一次“旋风斩效果”后场上有0个“恐怖的奴隶主”。又如,场上有6个生命值为3的“恐怖的奴隶主”,则一次“旋风斩效果”后场上有6个2点生命的“恐怖的奴隶主”以及1个3点生命的“恐怖的奴隶主”。又如,场上有4个1点生命的“恐怖的奴隶主”以及2个2点生命的“恐怖的奴隶主”,则一次“旋风斩效果”后场上有2个1点生命的“恐怖的奴隶主”以及1个3点生命的“恐怖的奴隶主”。
现在场上有1个3点生命的“恐怖的奴隶主”,问n次“旋风斩效果”后场上有多少个“恐怖的奴隶主”,在这n次“旋风斩效果”每次结束时,场上存在“恐怖的奴隶主”最多的个数是多少。
Input
第1行输入一个k(1<=k<=100000)代表有接下来有k组数据。
第2到k+1行 每行输入一个n(0<=n<=10^9),意义如前文所述。
Output
对于每一组数据,用一行输出组数, 1个3点生命的“恐怖的奴隶主”,在n次“旋风斩效果”后场上有多少个“恐怖的奴隶主”,以及在这n次“旋风斩效果”每次结束时,场上存在“恐怖的奴隶主”最多的个数是多少。具体格式见样例。
Sample Input
2
2
4
Sample Output
Case 1: 4 4
Case 2: 6 6

#include <cstdio>
#include <cmath>
using namespace std;

typedef long long LL;
int t, n, ans[] = {1,2,4,6,6,5};

int main() {
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
#endif
  scanf("%d", &t);
  for (int i = 1; i <= t; ++i) {
    scanf("%d", &n);
    printf("Case %d: %d %d\n", 
      i,
      n < 3 ? ans[n] : ans[(n - 2) % 4 + 2],
      n < 3 ? ans[n] : 6);
  }
  return 0;
}

1724 Problem E 相等距离的和

1725 Problem F 加尔鲁什·地狱咆哮对阵虚灵大盗拉法姆

1726 Problem G 你经历过绝望吗?两次!

/*
Description
416日,日本熊本地区强震后,受灾严重的阿苏市一养猪场倒塌,幸运的是,猪圈里很多头猪依然坚强存活。当地15名消防员耗时一天解救围困的“猪坚强”。不过与在废墟中靠吃木炭饮雨水存活36天的中国汶川“猪坚强”相比,熊本的猪可没那么幸运,因为它们最终还是没能逃过被送往屠宰场的命运。
我们假设“猪坚强”被困在一个N*M的废墟中,其中“@”表示“猪坚强”的位置,“.”表示可以直接通过的空地,“#”表示不能拆毁的障碍物,“*”表示可以拆毁的障碍物,那么请问消防员至少要拆毁多少个障碍物,才能从废墟中救出“猪坚强”送往屠宰场?(当“猪坚强”通过空地或被拆毁的障碍物移动到废墟边缘时,视作被救出废墟)
Input
多组数据,第一行有一个整数T,表示有T组数据。(T<=100)
以下每组数据第一行有两个整数N和M。(1<=N,M<=100)
接着N行,每行有一个长度为M的字符串。
Output
一个整数,为最少拆毁的障碍物数量,如果不能逃离废墟,输出-1。

Sample Input
3
3 3
###
#@*
***
3 4
####
#@.*
**.*
3 3
.#.
#@#
.#.
Sample Output
1
0
-1
*/

特别注意,本题数据有问题,@有可能有多个,只救第一个

#include <cstdio>
#include <queue>
#include <cstring>
using namespace std;

const int SIZE = 110;

class Node {
public:
  int x, y, cost;
  Node(int a, int b, int c) {
    x = a; y = b; cost = c;
  }
  bool operator < (const Node &a) const {
    return cost > a.cost;
  }
};

int t, n, m, sx, sy;
int dirx[] = {0, 1, 0, -1}, diry[] = {1, 0, -1, 0};
int cnt[SIZE][SIZE];
char gra[SIZE][SIZE];

int Bfs() {
  memset(cnt, 0x3f, sizeof(cnt));
  priority_queue<Node> q;
  q.push(Node(sx, sy, 0));
  cnt[sx][sy] = 0;
  while (!q.empty()) {
    Node head = q.top(); q.pop();
    if (head.x == 0 || head.y == 0 || head.x == n - 1 || head.y == m - 1) {
      return head.cost;
    }
    for (int i = 0; i < 4; ++i) {
      int nx = dirx[i] + head.x;
      int ny = diry[i] + head.y;
      if (nx >= 0 && ny >= 0 && nx < n && ny < m) {
        if (gra[nx][ny] == '.' && cnt[nx][ny] > head.cost) {
          q.push(Node(nx, ny, head.cost));
          cnt[nx][ny] = head.cost;
        } else if (gra[nx][ny] == '*' && cnt[nx][ny] > head.cost + 1) {
          q.push(Node(nx, ny, head.cost + 1));
          cnt[nx][ny] = head.cost + 1;
        }
      }
    }
  }
  return -1;
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
#endif
  scanf("%d", &t);
  while (t--) {
    scanf("%d%d%*c", &n, &m);
    for (int i = 0; i < n; ++i) {
      scanf("%s%*c", gra[i]);
    }
    bool get = false;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m && !get; ++j) {
        if (gra[i][j] == '@') {
          sx = i; sy = j; get = true; break;
        }
      }
    }
    printf("%d\n", Bfs());
  }
  return 0;
}

1727 Problem H The Fake Coin

Description
There are n coins,one of them is fake.The fake coin is heavier than a genuine one.If you have a balance,how many times at least you need to use it to find the fake coin?

Input
The first line contains an integer T (T<=100), means there are T test cases.
For each test case, there is only one line with an integer n (1 <= n <= 10000). The num of coins.

Output
For each test case, output the least times you need.

Sample Input
3
2
3
4
Sample Output
1
1
2

#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

typedef long long LL;
const int SIZE = 1e4 + 10;
int t, n, ans[] = {0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 3};

int Find(int a1) {
  if (a1 <= 10) {
    return ans[a1];
  }
  return 1 + Find(ceil((double)a1/3));
}

int main() {
  scanf("%d", &t);
  for (int i = 0; i < t; ++i) {
    scanf("%d", &n);
    printf("%d\n", Find(n));
  }
  return 0;
}

1728 Problem I 线形逐步共聚合反应

1729 Problem J 齿轮传动

1730 Problem K Tractatus Logico-Philosophicus

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值