跳到正文

nianbo123

1406600

ZJ-TZ小六蒟蒻,主团:112324,出题组需考核,先加入主团,参加发主团讨论区

在洛谷打开
资料、奖项与版本

资料

编号
1406600
抓取

陶片放逐

− 发送私信

查看记录

2021级的六年级蒟蒻

浙江台州温岭,台州信息素养大赛一等,csp-j省一到省二水平,复赛波动

sutong=wow!score300+!!!−−−dieluo=NO!200−sutong=wow!score300+!!! ---dieluo=NO!200-

超级大

数学人教版初中”。”

不太会用这个数学公式。。。下面的式子2a\frac{下面的式子}{2a} −b-b ±(b2−4ac)\pm \sqrt(b^2-4ac)

几乎无法场切黄题,但手切过两道青题P2303,P11961,学习内容普及强化

GESP 1级2503 100分,3级2506 55分,2509 65.5分,4级2512 0分(小意外),2603 51分,2606 86分,5级2609 67.5分,6级202612 分

向前冲

初墨,多么优雅的名字——可惜他姓熊。

拔杰,多么高端的名字——可惜他姓朱。

渔歌,多么诗意的名字——可惜他姓章。

楚衢,多么凝重的名字——可惜他姓滚。

巅峰,多么上进的名字——可惜他姓杨。

紫藤,多么大气的名字——可惜他姓杜。

晶斌,多么文静的名字——可惜他姓沈。

泥马,多么深奥的名字——可惜他姓曹。

珍香,多么秀丽的名字——可惜他姓史。

达野,多么磅礴的名字——可惜他姓尼。

仁范,多么仁慈的名字——可惜他姓沙。

暴力出奇迹,骗分过样例。

数学先打表,DP靠运气。

穷举TLE,递推UKE。

模拟MLE,贪心还CE。

想要骗到分,就要有方法。

图论背模板,数论背公式。

动规背方程,高精背代码。

如果都没背,干脆g回家!

石化算数:

代码通道
C++
#include<bits/stdc++.h>
using namespace std;
#define fd double
#define zf char
fd a, b;
string s;
stack<fd> n;
stack<zf> o;
int f(zf c) {
    if(c=='^') return 3;
    if(c=='*'||c=='/') return 2;
    if(c=='+'||c=='-') return 1;
    return 0;
}
fd cal(fd a,fd b,zf c){
    if(c=='^') return pow(a,b);
    if(c=='*') return a*b;
    if(c=='/') return a/b;
    if(c=='+') return a+b;
    return a-b;
}
int main()
{
    cin>>s;
    for(int i=0;i<s.size();i++){
        if (isdigit(s[i])){
            fd x=0;
            while(i<s.size()&&isdigit(s[i])){
                x=x*10+s[i]-'0';
                i++;
            }
            if(i<s.size()&&s[i]=='.'){
                i++;
                fd dec=0.1;
                while(i<s.size()&&isdigit(s[i])){
                    x+=(s[i]-'0')*dec;
                    dec*=0.1;
                    i++;
                }
            }
            n.push(x);
            i--;
        }
        else if(s[i]=='(') o.push(s[i]);
        else if(s[i] == ')'){
            while(!o.empty()&&o.top()!='(') {
                b=n.top();
                n.pop();
                a=n.top();
                n.pop();
                n.push(cal(a,b,o.top()));
                o.pop();
            }
            if(!o.empty()) o.pop();
        }
        else{
            if((s[i]=='+'||s[i]=='-')&&(i==0||s[i-1]=='('||f(s[i-1])>0)){
                if(s[i]=='-'){
                    i++;
                    if(i<s.size()&&isdigit(s[i])){
                        fd x=0;
                        while(i<s.size()&&isdigit(s[i])){
                            x=x*10+s[i]-'0';
                            i++;
                        }
                        if(i<s.size()&&s[i]=='.'){
                            i++;
                            fd dec=0.1;
                            while(i<s.size()&&isdigit(s[i])){
                                x+=(s[i]-'0')*dec;
                                dec*=0.1;
                                i++;
                            }
                        }
                        n.push(-x);
                        i--;
                    }
                    else if(i<s.size()&&s[i]=='('){
                        n.push(0);
                        o.push('-');
                        i--;
                    }
                }
                else{
                    i++;
                    if(i<s.size()&&isdigit(s[i])){
                        fd x=0;
                        while(i<s.size()&&isdigit(s[i])){
                            x=x*10+s[i]-'0';
                            i++;
                        }
                        if(i<s.size()&&s[i]=='.'){
                            i++;
                            fd dec=0.1;
                            while(i<s.size()&&isdigit(s[i])){
                                x+=(s[i]-'0')*dec;
                                dec*=0.1;
                                i++;
                            }
                        }
                        n.push(x);
                        i--;
                    }
                    else if(i<s.size()&&s[i]=='('){
                        n.push(0);
                        o.push('+');
                        i--;
                    }
                }
                continue;
            }
            while(!o.empty()&&((s[i]!='^'&&f(o.top())>=f(s[i]))||(s[i]=='^'&&f(o.top())>f(s[i])))){
                b=n.top();
                n.pop();
                a=n.top();
                n.pop();
                n.push(cal(a,b,o.top()));
                o.pop();
            }
            o.push(s[i]);
        }
    }
    while(!o.empty()){
        b=n.top();
        n.pop();
        a=n.top();
        n.pop();
        n.push(cal(a,b,o.top()));
        o.pop();
    }
    printf("%.2f",n.top());
}
共 2 篇