BestCoder Round #36 HDU 5199 Gunner

本文介绍了如何使用C++中的map容器直接读取数据,并通过示例代码展示了其简便性和效率。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

用map可以用&直接读取数据。。简直方便

#include "string"
#include "iostream"
#include "cstdio"
#include "cmath"
#include "algorithm"
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef long long LL;
const int M=55;

map<int,int>p;

inline int read()
{
    char ch=getchar();
	int x=0,f=1;
    while(ch>'9'||ch<'0')
	{
		if(ch=='-')
	    f=-1;
	    ch=getchar();
	}
    while(ch<='9'&&ch>='0')
	{
		x=x*10+ch-'0';
	    ch=getchar();
	}
    return x*f;
}

int main()
{
    int n,m;
    while(~scanf("%d %d",&n,&m))
    {
        int t;
        p.clear();
        for(int i=0;i<n;i++)
        {
            t=read();
            p[t]=10;
        }
        while(m--)
        {
            t=read();
            int &c=p[t];
            printf("%d\n",c);
            c=0;
        }
    }
    return 0;
}


 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值