• [LuoguP4711]分子质量(小模拟+玛丽题)


    ……这个题我居然可以把他(1A)……真是让我不知其可(qwq)

    (Link)

    (emmmm)好像发现了什么固定的套路(?)……

    大概就是这种题总会有

    1、读入数 方案:快读即可。

    2、鬼畜的优先级 方案:只要代码敲不死,就往死里敲代码(qwq)——特判

    3、“数 + 数据”的运算 方案:跟着感觉走……

    (emmm)第三条是真的!不是水水!这道题里的关键部分(即小括号的判读以及运算)由于是后缀形式,所以需要多操作一下(qwq)但我并没有特别缜密的思考就给搞完了

    诶?被你发现了?其实我就是来存个代码的(qwq),甚至连题目描述都没有……

    #include <map>
    #include <cstdio>
    #include <cstring>
    #include <iostream>
    
    int flag = 0 ;
    using namespace std ;
    const int MAXN = 210 ;
    map<string, double> a ;
    string s, qwq ; int N, i ;
    double ans, res, Last, j ;
    
    inline void init(){
        a["H"]=1; a["C"]=12; a["N"]=14; a["O"]=16;
        a["F"]=19; a["Na"]=23; a["Mg"]=24; a["Al"]=27;
        a["Si"]=28; a["P"]=31; a["S"]=32; a["Cl"]=35.5;
        a["K"]=39; a["Ca"]=40; a["Mn"]=55; a["Fe"]=56;
        a["Cu"]=64; a["Zn"]=65; a["Ag"]=108; a["I"]=127;
        a["Ba"]=137; a["Hf"]=178.5; a["Pt"]=195; a["Au"]=197;
        a["Hg"]=201;
    }
    inline int r_int(int x, int &q){
        res = 0 ;
        while(s[x] <= '9' && s[x] >= '0')
            res = res * 10 + s[x] - 48, x ++ ;
        q = x ;
        return res ;
    }
    inline double r_char(int x, int &q){
        double ret = 0, T ; bool mark = 0 ;
        if(x && s[x - 1] == '(') flag ++, mark = 1 ;
        while(x <= N && (s[x] > '9' || s[x] < '0') && s[x] != '~' ){
            if(s[x] == '(') x += 1, ret += r_char(x, x) ;
            if(s[x] == ')') {x ++ ; break ;}
            if(s[x + 1] <= 'z' && s[x + 1] >= 'a')
                {string now ; now = now + s[x] + s[x + 1]; x ++, ret += a[now], qwq = now ;}
            else if(s[x] <= 'Z' && s[x] >= 'A') {string now ; now += s[x] ; qwq = now, ret += a[now] ;}
            else if(s[x] == '_'){
                x += 2, T = r_int(x, x) ;
                if(!flag || mark)ret += a[qwq] * (T - 1) ;
                else {
                    flag -- ;
                    ret += (T - 1) * Last ;
                }
            }
            x ++ ;
        }
        q = x ; if(flag) Last = ret ;
        return ret ;
    }
    int main(){
        cin >> s ; N = s.size() ;init() ;
        for(i = 0; i <= N ; i ++){
            if(s[i] == '~') continue ;
            j = r_int(i, i) ; if(!j) j = 1.0 ;
            ans += r_char(i, i) * j ;
        }
        cout << ans ;
    }
    
    
  • 相关阅读:
    静态代码块--》非静态代码块--》构造方法
    谈谈SQL server的 worker threads-----微软亚太区数据库技术支持组 官方博客
    SQL SERVER SQLOS的任务调度--微软亚太区数据库技术支持组 官方博客
    线程池 数据库连接池 内存池
    SQL Server的thread scheduling(线程调度)
    ookla 网络上传下载 PING 测试
    mysql 监控工具
    SQL Server 2000 ——系统表和系统视图
    SQL Server 2000 ——DBCC命令
    几个未公开的 DBCC 命令
  • 原文地址:https://www.cnblogs.com/pks-t/p/9364425.html
Copyright © 2020-2023  润新知