2021级的六年级蒟蒻
浙江台州温岭,台州信息素养大赛一等,csp-j省一到省二水平,复赛波动
超级大
数学人教版初中”。”
不太会用这个数学公式。。。
几乎无法场切黄题,但手切过两道青题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回家!
石化算数:
代码通道
#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());
}