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<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map> #define eps 1e-6 using namespace std; map<string,int> mp; int main()
{
int n,m;
double k;
cin>>n>>m>>k;
string name;
int exp;
for(int i=;i<n;i++)
{
cin>>name>>exp;
exp=exp*k+eps; //注意:这里是卡精度,要加上行1e-6才能过
if(exp>=) //判断是否大于或等于100
mp[name]=exp;
}
for(int i=;i<m;i++)
{
cin>>name;
if(mp[name]==)
mp[name]=;
}
cout<<mp.size()<<endl;
for(map<string,int>::iterator it=mp.begin();it!=mp.end();it++) //map容器里是按字典序存放的
cout<<it->first<<" "<<it->second<<endl;
return ;
}

A. Transmigration的更多相关文章

  1. Codeforces Beta Round #81 A Transmigration

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

  2. CODEFORCES problem 105A.Transmigration

    题目本身上手并不难,字符串处理+简单的排序.要注意的地方是浮点数的处理. 依据计算机中浮点数的表示原理,在实际编程的过程中即使用一个确定的整数(假设是1)给一个浮点变量赋值 在查看变量时会发现实际存储 ...

  3. [Reship]如何回复审稿人意见

    ================================= This article came from here:http://blog.renren.com/GetEntry.do?id= ...

  4. python瓦登尔湖词频统计

    #瓦登尔湖词频统计: import string path = 'D:/python3/Walden.txt' with open(path,'r',encoding= 'utf-8') as tex ...

随机推荐

  1. HTML5自学之列表

    第5章. 网页列表与段落设计网页列表与段落是网页中的主要也是最常用的元素,其中,网页列表可以有序地编排一些信息资源,使其结构化和条理化,并以列表的样式显示出来,以便浏览者能更加快捷的获得相应信息.网页 ...

  2. 集成学习-Boosting 模型深度串讲

    首先强调一下,这篇文章适合有很好的基础的人 梯度下降 这里不系统讲,只介绍相关的点,便于理解后文 先放一个很早以前写的 梯度下降 实现 logistic regression 的代码 def tidu ...

  3. CE修改器使用教程 [入门篇]

    Cheat Engine 一般简称CE,是一个开放源代码的作弊软件,其功能包括:内存扫描.十六进制编辑器.调试工具,Cheat Engine 自身附带了外挂制作工具,可以用它直接生成外挂工具,CE可以 ...

  4. poj2226-Muddy Fields二分匹配 最小顶点覆盖 好题

    题目 给到一个矩阵,有些格子上是草,有些是水.需要用宽度为1,长度任意的若干块木板覆盖所有的水,并不能覆盖草,木板可以交叉,但只能横竖放置,问最少要多少块板. 分析 经典的矩阵二分图构图和最小点覆盖. ...

  5. Codeforces 1194C. From S To T

    传送门 首先贪心, $S$ 能和 $T$ 匹配就要尽量匹配,剩下的才让 $P$ 来补 在 $S$ 全部匹配上的情况下,看看 $P$ 是否有足够的字符即可 #include<iostream> ...

  6. Java排序--排序算法(内排序)

    常用内排序算法 我们通常所说的排序算法往往指的是内部排序算法,即需要排序的数据在计算机内存中完成整个排序的过程,当数据率超大或排序较为繁琐时常借助于计算机的硬盘对大数据进行排序工作,称之为外部排序算法 ...

  7. C# 面向对象1(类和对象的概念)

    1.面向过程-->面向对象 面向过程:面向的是完成这件事儿的过程,强调的是完成这件事儿的动作. 2.面向过程的思想: 以上的,需求一更改,会导致不同的方法,一一去更改. 3.面向对象的思想:找个 ...

  8. JS图片轮播[左右轮播

    直接可以用,网上摘下来的! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http ...

  9. PostMan测试Web Service

    1.设置URL 2.设置请求模式:Post 3.设置Header:添加 Content-Type ,值为 text/xml;charset=utf-8 4.设置Body:勾选raw 5.输入Body内 ...

  10. js之运算符其它运算符(三元运算符,逗号运算符,void运算符,typeof,delete运算符)

    Javascript支持很多其它的运算符,具体如下: 一.条件运算符(?:) 条件运算符是Javascript中唯一的三个操作数的三元运算符,有时会直接称做是“三元运算符”. 基本格式:conditi ...