HDU --- 2018 Multi-University Training Contest 6

36 篇文章 0 订阅
34 篇文章 3 订阅

这套题一定要写篇博客!!!做的真的太艰辛了!!从头到尾一直在怀疑人生!!明明都不是难题,但是题意真的是扯!!

1001:oval-and-rectangle

题意:给出以圆心为中点的椭圆的长轴a和短轴b,随机取x在区间[0,b]中,做平行于x轴的直线,做一个长方形,求其周长的期望

思路:基本的概率论的期望公式,但是一点是周长公式没有画图,,少算了一半的周长,,再就是√(a^2-x^2)的积分公式忘记了,,现搜的,最想打死自己的是!!积分后的arctan1=90°!!生生换弧度换成了Π/4!!!大约得有半个小时的时间就卡在这个地方!!!换了n种求期望方式!!都死在这里!!!真的是WA。。。最后求出来,就很简单的一个公式,,见代码。

#include <bits/stdc++.h>
using namespace std;
const double PI=acos(-1.0);
int main()
{
    int T,a,b;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d%d",&a,&b);
        double ans=2.0*b+PI*a;
        cout<<fixed<<setprecision(6)<<(ans-0.0000005)<<endl;
    }
    return 0;
}

1009:Werewolf

题意:狼人杀游戏,,,n个人身份不明,每个人依次指证其他其中一位玩家的身份,村民一定说真话,狼人可以说假话,求在所有的可能性情况中,一定是村名的玩家的人数和一定是狼人的人数

思路:就是各种推,因为狼人既可以说假话也可以说真话,所以全部都是狼人的情况一定成立,也就是说在所有情况中都是村民的人数一定是0,然后就看狼人,每个人只有被自己指证的村名指证自己是狼人的情况,这个人一定是 狼人,再就是指证狼人是村民的人一定是狼人,就是想的分情况的时候很困难,实际代码并不难实现,但是把情况分出来是通过整个实验室的努力,,,

先找被自己指认的村民指证自己是狼人的情况,这一定是一个环,又因为每个人都只能指证一个玩家,所以出度一定是1,然后从入度为0的点开始遍历,把所有环外的线都去掉,要注意的是指向一个环的线,所以能便利的点一定要是入读为0的点,并且要即刻删边。然后只剩下环后从任一点遍历环,只有一个指认是狼人的环,被指认的人一定是狼人,然后从这个狼人向指认反向遍历,指认狼人是村民的一定是狼人,狼人身份明确就记录,不要重复指认,省时间

代码:

#include<bits/stdc++.h>
using namespace std;
int in[100005],f[100005],x[100005],look[100005],T,ans,n,v,tt[100005],pp[100005];
int ant[100005],mm;
char ch[15];
struct AA
{
    int v,c,next,wa;
}pos[100005];

void dfs(int rt)
{
    if(in[rt]) return;
    look[rt]=1;
    if(f[rt]&&!look[f[rt]])
    {
        in[f[rt]]--;
        dfs(f[rt]);
    }
    return;
}
void ww(int rt)
{
    pp[rt]=1;
    tt[rt]=1;
    ans++;
    int vv;
    for(int i=ant[rt];i!=-1;i=pos[i].next)
    {
        vv=pos[i].v;
        if(tt[vv]==0&&!pos[i].wa)
        {
            ww(vv);
        }
    }
    return;
}
void dd(int rt,int num,int p)
{
    look[rt]=1;
    num+=x[rt];
    p=(x[rt]==1?f[rt]:p);

    if(look[f[rt]]) {
        if(num!=1) return;
        ww(p);return;}
    if(look[f[rt]]==0)
    {
        in[f[rt]]--;
        dd(f[rt],num,p);
    }
    return;
}
int main()
{
    scanf("%d",&T);
    while(T--)
    {
        mm=0;
        ans=0;
        scanf("%d",&n);
        for(int i=0;i<=n;i++)
        {
            in[i]=look[i]=tt[i]=pp[i]=0;
            ant[i]=-1;
        }
        for(int i=1;i<=n;i++)
        {
            scanf("%d%s",&v,ch);
            f[i]=v;
            in[v]++;
            if(ch[0]=='w') x[i]=1;
            else x[i]=0;

            pos[++mm].v=i;
            pos[mm].next=ant[v];
            pos[mm].wa=x[i];
            ant[v]=mm;

        }
        for(int i=1;i<=n;i++)
        {
            if(in[i]==0&&look[i]==0)
            {
                dfs(i);
            }
        }
        for(int i=1;i<=n;i++)
        {
            if(in[i]&&look[i]==0)
            {
                dd(i,0,-1);}
        }
        printf("0 %d\n",ans);
    }
}
/*
100
5
2 vv
3 ww
1 vv
3 vv
4 vv
*/

1012  Pinball

题意:There is a slope on the 2D plane. The lowest point of the slope is at the origin. There is a small ball falling down above the slope. Your task is to find how many times the ball has been bounced on the slope.

It's guarantee that the ball will not reach the slope or ground or Y-axis with a distance of less than 1 from the origin. And the ball is elastic collision without energy loss. Gravity acceleration g=9.8m/s2.

思路:队友搜的网上论文,,直接套的公式,但是!!这个题我们WA+9!!四个人每个人都交了。。。有的代错了公式,,有的陷了死循环,,我!!就比较NB了,,因为同时用了cin和scanf和cout!!!所以TLE!!我真是惊了!!HDU竟还有这种操作!!

代码:

#include<bits/stdc++.h>
using namespace std;
double x,y,a,b,t,t1,c,v,h,l,ll,g,QQ;
double hx(double i)
{
    return 2*i*g*t1*t1*sin(2*QQ);
}
double hy(double i)
{
    return 4*i*g*t1*t1*sin(QQ)*sin(QQ);
}
int main()
{
    cin>>t;
    g=9.8;
    while(t--)
    {
        cin>>a>>b>>x>>y;
        QQ=atan(b/a);
        //cout<<QQ<<endl;
        a=-a;
        c=b/a*x;
        h=y-c;
        t1=sqrt(2*h/g);
        y=c;
        for(int i=1;i<=50;i++)
        {
            l=hx(i);
            ll=hy(i);
            if(l+x>0||y-ll<0) {cout<<i<<endl;break;}
            x+=l;
            y-=ll;
        }
    }
    return 0;
}

这次比赛真的是!!!!!心很痛!!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值