1 条题解

  • 1
    @ 2025-1-6 19:32:32

    官方题解(我是这题出题人):

    #include<bits/stdc++.h>
    using namespace std;
    int nm,temp;
    string str;
    char chr;
    map<char,int>mp;
    int main(){
        ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    	cin>>nm;
    	for(int i=1;i<=nm;++i){
    		cin>>str;
    		if(str=="define"){
    			cin>>chr>>temp;
    			mp[chr]=temp;
    		}
    		if(str=="plus"){
    			cin>>chr>>temp;
    			mp[chr]+=temp;
    		}
    		if(str=="minus"){
    			cin>>chr>>temp;
    			mp[chr]-=temp;
    		}
    		if(str=="times"){
    			cin>>chr>>temp;
    			mp[chr]*=temp;
    		}
    		if(str=="divide"){
    			cin>>chr>>temp;
    			mp[chr]/=temp;
    		}
    		if(str=="out"){
    			cin>>chr;
    			cout<<mp[chr]<<endl;
    		}
    	}
        return 0;  
    }
    

    信息

    ID
    49
    时间
    2000ms
    内存
    256MiB
    难度
    1
    标签
    递交数
    2
    已通过
    2
    上传者