博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
A. Transmigration
阅读量:5011 次
发布时间:2019-06-12

本文共 3938 字,大约阅读时间需要 13 分钟。

A. Transmigration

time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes are characterized by different skills.

Unfortunately, the skills that are uncommon for the given character's class are quite difficult to obtain. To avoid this limitation, there is the so-called transmigration.

Transmigration is reincarnation of the character in a new creature. His soul shifts to a new body and retains part of his experience from the previous life.

As a result of transmigration the new character gets all the skills of the old character and the skill levels are reduced according to the k coefficient (if the skill level was equal to x, then after transmigration it becomes equal to [kx], where [y] is the integral part of y). If some skill's levels are strictly less than 100, these skills are forgotten (the character does not have them any more). After that the new character also gains the skills that are specific for his class, but are new to him. The levels of those additional skills are set to 0.

Thus, one can create a character with skills specific for completely different character classes via transmigrations. For example, creating a mage archer or a thief warrior is possible.

You are suggested to solve the following problem: what skills will the character have after transmigration and what will the levels of those skills be?

Input

The first line contains three numbers nm and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal point (1 ≤ n, m ≤ 20, 0.01 ≤ k ≤ 0.99).

Then follow n lines, each of which describes a character's skill in the form "name exp" — the skill's name and the character's skill level: name is a string and exp is an integer in range from 0 to 9999, inclusive.

Then follow m lines each of which contains names of skills specific for the class, into which the character transmigrates.

All names consist of lowercase Latin letters and their lengths can range from 1 to 20characters, inclusive. All character's skills have distinct names. Besides the skills specific for the class into which the player transmigrates also have distinct names.

Output

Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order.

Examples

input

5 4 0.75 axe 350 impaler 300 ionize 80 megafire 120 magicboost 220 heal megafire shield magicboost

output

6 axe 262 heal 0 impaler 225 magicboost 165 megafire 0 shield 0 题意:玩过DNF的人都知道,每个角色到了18级就可以转职,换成一个新的职业,有新的技能。而这个题的意思是在未转职之前的技能点数大于或者等于100的,可以保留下来。而转职之后获得新的技能,如果那个技能在之前已经有点数了(这个点数必定是大于或等于100),那就不需要进行操作,如果没有的话,就将该技能点数赋值为0。本题有一个问题,就是会卡你精度,我就是因为这个测试数据19总是过不了,其他的就没什么注意的了。
#include
#include
#include
#include
#include
#define eps 1e-6using namespace std;map
mp;int main(){ int n,m; double k; cin>>n>>m>>k; string name; int exp; for(int i=0;i
>name>>exp; exp=exp*k+eps; //注意:这里是卡精度,要加上行1e-6才能过 if(exp>=100) //判断是否大于或等于100 mp[name]=exp; } for(int i=0;i
>name; if(mp[name]==0) mp[name]=0; } cout<
<
::iterator it=mp.begin();it!=mp.end();it++) //map容器里是按字典序存放的 cout<
first<<" "<
second<

 

转载于:https://www.cnblogs.com/buhuiflydepig/p/10635400.html

你可能感兴趣的文章
中文url编码乱码问题归纳整理一
查看>>
Cesium应用篇:3控件(3)SelectionIndicator& InfoBox
查看>>
58. Length of Last Word(js)
查看>>
前端面试题汇总(持续更新...)
查看>>
如何成为F1车手?
查看>>
QT自定义消息
查看>>
Save (Not Permitted) Dialog Box
查看>>
装饰模式(Decorator)
查看>>
任务13:在Core Mvc中使用Options
查看>>
利用Excel 2010数据透视图实现数字的可视化的图形直观展示
查看>>
Sort Colors
查看>>
iview树的修改某个节点,树刷新后自动展开你刚才展开的所有节点
查看>>
oracle服务起不来以及无法监听问题解决
查看>>
Mvc--Html.ActionLink()的用法
查看>>
delphi 基础书籍推荐
查看>>
《面向对象程序设计》2018年春学期寒假及博客作业总结
查看>>
iOS开发UI之KVC(取值/赋值) - KVO (观察某个对象的某个属性的改变)
查看>>
1.7 将一个MxN矩阵所有为0的元素所在行和列全部置0
查看>>
删除U盘时提示无法停止‘通用卷’设备的解决方法!!不要每次都硬拔了,对电脑有不小的损害!!!...
查看>>
Java中接口与接口和类之间的关系
查看>>