CodeForces 105A

Description

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 kcoefficient (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 ≤ 200.01 ≤ k ≤ 0.99).

Then follow n lines, each of which describes a character's skill in the form "nameexp" — 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 20 characters, 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.

Sample Input

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

题意,一个角色有n个技巧,每个技巧有相应的经验值,转职后,每个的经验值会变为原来的k倍,若转变后的经验值小于100,则忘掉该技能,转职后会学会新角色技能,若以前已经学会,则经验值不变,否则经验值为0;

思路,转职后经验值大于100加入map,否则舍弃,新技能直接加入map,经验值赋为0,

这道题卡精度,double类型变量强行取整会产生误差。因为100在计算机内部可能用99.99999999表示,所以先加上极小量EPS消除误差,在取整(我是先取得整,在加的EPS,已经没卵用了。。)

#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iostream>
#include<cmath>
#include<queue>
#include<map>
using namespace std;

int main(){
	freopen("input.txt","r",stdin);
	int n,m;
	double exp;
	double k;
	int num=0;
	string str;
	cin>>n>>m>>k;
	map<string,int> cnt;
	for(int i=0;i<n;i++){
		cin>>str>>exp;
//		exp=exp+1e-6;
		exp=exp*k;
		if(exp+1e-4<100) continue;
		cnt[str]=exp+1e-4;
	}
	for(int i=0;i<m;i++){
		cin>>str;
		if(cnt[str]>0) continue;
		cnt[str]=0;
	}
	
	num=cnt.size();
	cout<<num<<endl;
	map<string,int>::iterator it;
	for(it=cnt.begin();it!=cnt.end();it++){
		cout<<it->first<<" "<<it->second<<endl;
	}
	return 0;
}










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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值