洛谷2018.6月赛

  对于初中生来说简直就是阅读理解场,感觉之前自学的高中物理全白学了。

  T1:[物理]平抛运动:https://www.luogu.org/problemnew/show/P4710

  题意概述:怎么概述,我自己还没完全看懂呢...

  事实上是个名副其实的签到题。首先发现了一些公式,然后发现关键就是$t$,只要有了$t$,别的就都可以随便算啦。这时候就发现一个很奇妙的事情,$v_{yt}$好像给了两种表示方法?于是就可以把两种方法联立一下求出$t$来,就愉快的A掉这个题。(自作聪明的我把g当做9.8于是得了一次0分,一定要好好读题!!)竟然看题看了0.5h...

  
# include <cstdio>
# include <iostream>
# include <cmath>

using namespace std;

double v,th;
double t,vx,vy;
const double g=10.0;

int main()
{
    cin>>v>>th;
    vx=sin(th)*v;
    vy=cos(th)*v;
    t=vy/g;
    printf("%.15lf %.15lf",vx*t,0.5*t*t*g);
    return 0;
}
[物理]平抛运动

  

  T2:[化学]相对分子质量:https://www.luogu.org/problemnew/show/P4711

  题意概述:计算一个分子式的相对分子质量。

  巨型模拟,可与“时间复杂度”一题相媲美。因为这道题,我终于学会了map。现在再去看代码感觉非常佩服自己,如果不是洛谷表示这题没有部分分,我估计就骗一点分就放弃了,但是既然没有部分分,只好强行写了1.5h,写了150行去做这个题。

  
# include <cstdio>
# include <iostream>
# include <cstring>
# include <string>
# include <map>

using namespace std;

string a,no;
int l,h=0,ans=0,num;
map <string,int> m;

void init()
{
    m["H"]=10;
    m["C"]=120;
    m["N"]=140;
    m["O"]=160;
    m["F"]=190;
    m["Na"]=230;
    m["Mg"]=240;
    m["Al"]=270;
    m["Si"]=280;
    m["P"]=310;
    m["S"]=320;
    m["Cl"]=355;
    m["K"]=390;
    m["Ca"]=400;
    m["Mn"]=550;
    m["Fe"]=560;
    m["Cu"]=640;
    m["Zn"]=650;
    m["Ag"]=1080;
    m["I"]=1270;
    m["Ba"]=1370;
    m["Hf"]=1785;
    m["Pt"]=1950;
    m["Au"]=1970;
    m["Hg"]=2010;
}

int main()
{
    cin>>a;
    l=a.length();
    init();
    h=0;
    no="";
    while (h!=l)
    {
        if(a[h]=='(')
        {
            int s=0;
            h++;
            while (a[h]!=')')
            {
                no="";
                if(a[h]>='A'&&a[h]<='Z')
                {
                    if(a[h+1]<='z'&&a[h+1]>='a') no+=a[h],no+=a[h+1],h++;
                        else no+=a[h];
                }
                if(a[h+1]!='_')
                {
                    s+=m[no];
                    no="";
                }
                else
                {
                    h=h+3;
                    num=0;
                    while (a[h]>='0'&&a[h]<='9')
                    {
                        num=(num<<3)+(num<<1)+(a[h]^48);
                        h++;
                    }
                    s+=num*m[no];
                    no="";
                }
                h++;
            }
            if(a[h+1]!='_')
                ans+=s;
            else
            {
                h=h+3;
                num=0;
                while (a[h]>='0'&&a[h]<='9')
                {
                    num=(num<<3)+(num<<1)+(a[h]^48);
                    h++;
                }
                ans+=num*s;
                no="";
            }
        }
        else  if(a[h]=='~')
        {
            h++;
            if(a[h]=='H')
                ans+=180;
            else
            {
                num=0;
                while (a[h]>='0'&&a[h]<='9')
                {
                    num=(num<<3)+(num<<1)+(a[h]^48);
                    h++;
                }
                ans+=num*180;
                no="";
            }
            h+=5;
        }
        else if(a[h]>='A'&&a[h]<='Z')
        {
            if(a[h+1]<='z'&&a[h+1]>='a') no+=a[h],no+=a[h+1],h++;
            else no+=a[h];
            if(a[h+1]!='_')
            {
                ans+=m[no];
                no="";
            }
            else
            {
                h=h+3;
                num=0;
                while (a[h]>='0'&&a[h]<='9')
                {
                    num=(num<<3)+(num<<1)+(a[h]^48);
                    h++;
                }
                ans+=num*m[no];
                no="";
            }
        }
        h++;            
    }
    if(ans%10) 
        printf("%.1lf",ans*0.1);
    else
        printf("%d",ans/10);
    return 0;
}
[化学]相对分子质量

  T3:[生物]能量流动:https://www.luogu.org/problemnew/show/P4712

  题意概述:食物网上有许多能量在流动!我也概括不了这题在讲啥。

  没做...主要是没有空了,其实是很简单的,本来可以做的,然而T2写的太久。

  因为能量每传递一层就损失很多,所以要尽量少传递几层,看起来像是个贪心,事实上也是。每种生物尽量从编号小的物种开始吃,而且只吃到最低点就可以了,

    事实上这题挺坑的,虽然题目描述没提输出位数,可是观察样例输出7位是最好的,用cout就会被卡精度...这种卡精度的题就是应该用IOI赛制考才比较好呢。

  
# include <cstdio>
# include <iostream>
# include <cmath>
# define R register int

using namespace std;

int rx,n,s,h=0;
double a[100005];
int r[100005];
char rc;

int read()
{
    rx=0;
    rc=getchar();
    while(!isdigit(rc))
        rc=getchar();
    while (isdigit(rc))
    {
        rx=(rx<<3)+(rx<<1)+(rc^48);
        rc=getchar();
    }
    return rx;
}

int main()
{
    scanf("%d%d",&n,&s);
    a[0]=s;
    for (R i=1;i<=n;++i)
    {
        scanf("%lf",&a[i]);
        r[i]=read();
    }
    for (int i=1;i<=n;++i)
    {
        double nu=0;
        while (nu<a[i])
        {
            if(h>r[i])
            {
                cout<<-1;
                return 0;    
            }
            if((a[i]-nu)*5<=a[h])
            {
                a[h]-=(a[i]-nu)*5;
                nu=a[i];
            }
            else
                nu+=a[h]*0.2,a[h]=0,h++;
        }
    }
    double res=0;
    for (int i=0;i<=n;++i)
        res+=a[i]*0.2;
    printf("%.7lf",res);
    return 0;    
}
[生物]能量流动

  T4:[语文]凑字数:https://www.luogu.org/problemnew/show/P4713

  题意最好理解的题没有之一。

  然而我就是不会这也没有什么办法。

  T5:[数学]因子个数和:https://www.luogu.org/problemnew/show/P4714

  题意概述:求一个数的因子的因子的因子的(*k)的因子个数和。

  听讲评的唯一收获就是这道题听懂了一点。$Pollard-rho$和矩阵快速幂/组合数。

  T6:[英语]Z语言:https://www.luogu.org/problemnew/show/P4715

  字符串匹配,听说要用平衡树,所以这道题明年再见吧。

  

  最后展示一下我很23333的成绩:

  

    讲评挺有意思的(打扰了),但是感觉并不能靠讲评听懂不会的题...下次看看电子版题解就行了(感觉月赛讲评有点晚,听到23:00之后感觉神情恍惚)。

   那么,洛谷月赛,下个月再见。

原文地址:https://www.cnblogs.com/shzr/p/9196742.html