计算器弹琴

QAQ
计算器版极乐净土
giligili

恩,这道题目前面的都没有用
-根本不用特殊处理,直接当普通字符处理就行了。。。。

#include
#include
#include
#include
#include
#include 
#include
using namespace std;
double ans;
string s;
int main()
{
    int n,v;
    scanf("%d%d",&n,&v);
    while(cin>>s)
    {
        int len=s.length();
        double numl=0;//未匹配的左括号
        for(int i=0;iif(s[i]==' ') continue;
            if(s[i]=='\n') break;
            if(s[i]=='(')
            {
                numl++;
                continue;
            } 
            if(s[i]==')') 
            {
                numl--;
                continue;
            }
            if(s[i]=='.') 
            {
                ans+=pow(0.5,numl+1);//加上前面的的1/2
                if(s[i-1]=='-') ans+=0.5;//特殊处理1-.的情况
                continue;
            }
            ans+=pow(0.5,numl);//普通字符
        }
    }
    printf("%d",(int)ans*60/v);

    return 0;
}
}

你可能感兴趣的:(题目分析,模拟)