首页 > 其他 > 详细

洛谷P2786 英语1(eng1)- 英语作文——map

时间:2019-12-07 01:33:02      阅读:139      评论:0      收藏:0      [点我收藏+]

给一手链接 https://www.luogu.com.cn/problem/P2786

拿这道题当map模板练练手qwq

技术分享图片
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
#include<iostream>
using namespace std;
int read(){
    int ans=0,f=1,c=getchar();
    while(c<0||c>9){if(c==-) f=-1; c=getchar();}
    while(c>=0&&c<=9){ans=ans*10+(c-0); c=getchar();}
    return ans*f;
}
int n,mod,ans;
char c;
string s;
map<string,int> q;
int pd(char c){
    if(c== ||c==,||c==.||c==!||c==?) return 0;
    return 1;
}
int main(){
    n=read(); mod=read();
    for(int i=1;i<=n;i++) cin>>s,q.insert(pair<string,int>(s,read()));
    s="";
    while((c=getchar())!=EOF){
        if(pd(c)) s+=c;
        else ans=(ans+q[s])%mod,s="";
    }
    printf("%d\n",ans);
    return 0;
}
View Code

 

洛谷P2786 英语1(eng1)- 英语作文——map

原文:https://www.cnblogs.com/yourinA/p/12000312.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!