zoukankan      html  css  js  c++  java
  • P2614 计算机弹琴

    https://www.luogu.org/problem/show?pid=2614
    这是一道模拟题,就是细节有点多。
    首先,括号里没有 - ,所以是 - 时,直接当成音符处理,又因为没有超过4个节拍的音符,所以遇到‘.’,判断前面是不是 - ,与普通字符分开处理就可以了。

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<cmath>
    using namespace std;
    int n,v;
    double ans=0;
    char aa[301];
    char a[301];
    int main()
    {
        int numl=0,numr=0;
        scanf("%d%d",&n,&v);
        while(cin>>a)
        {
            int L=strlen(a);
            double last=0; 
            for(int j=0;j<L;j++)
            {
    
                if(a[j]==' ') continue;
                if(a[j]=='(') {numl++;continue;} 
                if(a[j]==')') {numr++;continue;} 
                double p=pow(0.5,numl-numr);
                if(a[j]=='.') {ans+=0.5*p;if(a[j-1]=='-') ans+=0.5;continue;}
                ans+=p;
            }
        }
        ans=ans*60.0/v;
        printf("%d",(int)ans);
        return 0;
    } 
  • 相关阅读:
    vgcreate语法
    lsmod语法
    lvm语法2
    lvm语法
    mount语法
    fdisk语法
    mdadm语法
    ln语法
    mknod语法
    黑客常用dos-cmd命令
  • 原文地址:https://www.cnblogs.com/dfsac/p/7587847.html
Copyright © 2011-2022 走看看