在魔界战记中有一个设定叫做转生,当一个人物转生时,会保留之前的技能,但是技能等级需要乘以一个系数 k ,如果技能等级小于100,将会在转生之后失去该技能。

转生之后,会学到一些新技能。这些新技能附加的等级为0。

现在给你 n 个已有的技能,m个新技能和系数k,请按字典序输出转生之后的技能总数、技能名称和等级。

  这题最纠结蛋疼的地方就是不能使用强制类型转换和系统函数floor()。

  从样例输出来看,技能等级是向下取整的(350*0.75=262.5)。但是如果使用强制类型转换或者是用floor()函数的话,会有一组奇葩的数据卡住(floor(8700*0.94) = (int)(8700*0.94) = 8177,我也不知道谁出的这么操蛋好的数据,反正就是这里卡死了。这里的结果应该为8178)。

  然后其他的很简单了,将已有技能读取之后,等级小于100的直接去掉,转换之后小于100的变成0。然后开始读取新技能,读取一个遍历一次看是否存在这个技能(最多才20 * 20,不超时),存在继续,不存在就加入这个新技能。最后按照字典序排序输出就Ok了。

附AC代码,手残勿喷:

   1: #include <cstdio> 

   2: #include <cstdlib>

   3: #include <cstring>

   4: #include <cmath>

   5: #include <algorithm>

   6: #include <iostream>

   7: #include <string>

   8: #include <map>

   9: using namespace std;

  10:  

  11: class Skill

  12: {

  13:     public:

  14:         int lv;

  15:         string name;

  16:         Skill()

  17:         {

  18:             name.clear();

  19:             lv = 0;

  20:         }

  21:         bool operator < (const Skill &tmp) const

  22:         {

  23:             return name < tmp.name;

  24:         }

  25: }skill[59];

  26:  

  27: int Floor(double a)

  28: {

  29:     int res = a;

  30:     if (a - res >= 0.999999)

  31:         return (res + 1);

  32:     return res;

  33: }

  34:  

  35: string tmp;

  36: int tlv;

  37:  

  38: int main()

  39: {

  40:     int n, m, all = 0;

  41:     double k;

  42:     while(cin >> n >> m >> k)

  43:     {

  44:         all = 0;

  45:         for (int i = 1; i <= n; i++)

  46:         {

  47:             bool flag = 1;

  48:             cin >> tmp >> tlv;

  49:             for (int j = 1; j <= all && flag; j++) 

  50:                 if (skill[j].name == tmp) 

  51:                     flag = 0;

  52:             if (flag)

  53:             {

  54:                 if (Floor(tlv * k) >= 100)

  55:                 {

  56:                     all += 1;

  57:                     skill[all].name = tmp;

  58:                     skill[all].lv = Floor(tlv * k);

  59:                 }

  60:             }

  61:         }

  62:         for (int i = 1; i <= m; i++)

  63:         {

  64:             bool flag = 1;

  65:             cin >> tmp;

  66:             for (int j = 1; j <= all && flag; j++)

  67:                 if (skill[j].name == tmp)

  68:                     flag = 0;

  69:             if (flag)

  70:             {

  71:                 all += 1;

  72:                 skill[all].name = tmp;

  73:                 skill[all].lv = 0;

  74:             }

  75:         }

  76:         cout << all << endl;

  77:         sort(skill+1, skill+all+1);

  78:         for (int i = 1; i <= all; i++)

  79:         {

  80:             cout << skill[i].name << " " << skill[i].lv << endl;

  81:             skill[i].name.clear(); 

  82:             skill[i].lv = 0;

  83:         }

  84:     }

  85:     return 0;

  86: }

Codeforces Beta Round #81 A Transmigration的更多相关文章

  1. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  2. Codeforces Beta Round #62 题解【ABCD】

    Codeforces Beta Round #62 A Irrational problem 题意 f(x) = x mod p1 mod p2 mod p3 mod p4 问你[a,b]中有多少个数 ...

  3. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  4. Codeforces Beta Round #13 C. Sequence (DP)

    题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...

  5. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

  6. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

  7. Codeforces Beta Round #76 (Div. 2 Only)

    Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...

  8. Codeforces Beta Round #75 (Div. 2 Only)

    Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...

  9. Codeforces Beta Round #74 (Div. 2 Only)

    Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...

随机推荐

  1. 更新自带pip

    想安装docker-compose发现居然找不到pip curl https://bootstrap.pypa.io/get-pip.py | python 直接sudo不行.还是提示权限不够. su ...

  2. C++STL3--queue

    C++STL3--queue 一.心得 STL的这些东西用法都差不多 二.介绍 queue数据结构中的队列 priority_queue优先队列,插入进去的元素都会从大到小排好序 PS:在priori ...

  3. 雷林鹏分享:C# 运算符重载

    C# 运算符重载 您可以重定义或重载 C# 中内置的运算符.因此,程序员也可以使用用户自定义类型的运算符.重载运算符是具有特殊名称的函数,是通过关键字 operator 后跟运算符的符号来定义的.与其 ...

  4. hdoj2476 String painter

    题意:有一刷子,能将区间内涂成同一字母.给出src,dst串,问最少涂几次? 用dp[i][j]表示区间[i,j]内最少涂的次数.len=1,2时很明显.len=3时,dp[i][j]要么就在dp[i ...

  5. 关于"架构"

    杨光辉说,在构架系统的早期可能不会更多地考虑架构,主要是在做技术选型,首先是编程语言的选择.对于编程语言选择,当前主流编程语言有很多,有面向对象语言.传统式语言等.做这个选择主要根据人员知识储备,包括 ...

  6. python-day6---流程控制

    # if 条件:# 子代码1# 子代码2# 子代码3 # if True:# print('ok')# print('=====?>')# print('=====?>')# print( ...

  7. nyoj 1237 简单dfs

    最大岛屿 时间限制:1000 ms  |  内存限制:65535 KB 难度:2   描述 神秘的海洋,惊险的探险之路,打捞海底宝藏,激烈的海战,海盗劫富等等.加勒比海盗,你知道吧?杰克船长驾驶着自己 ...

  8. 此纳税人登记号已用于同一期间的交易方(交易方类型为 XXX 且交易方名称为 xxxx)。

    When updated Supplier's tax informations , System occurs a error:'This tax registration number is al ...

  9. Eureka服务注册过程详解之IpAddress(详解eureka.instance.prefer-ip-address = true 与 eureka.instance.prefer-ip-address)

    分析,eureka.instance.prefer-ip-address 本节解释为什么配置eureka.instance.prefer-ip-address = true时,注册到Eureka Se ...

  10. Css的向左浮动、先右浮动、绝对定位、相对定位的简单使用

    1.div层的浮动 1)div向左浮动.向右浮动 <!doctype html> <html> <head> <meta charset="utf- ...