玲珑杯 Round #11 (1001 1004 1007)

比赛链接

直接贴代码。。

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

int main()
{
    LL a,b,n;
    while(cin>>a>>b>>n)
    {
        LL sum=1e18;
        LL ans;
        for(LL i=1;i*i<=n;i++) if(n%i==0)
        {
            LL t=a*n/i+b*n*i;
            if(t<sum)
            {
                sum=t;
                ans=i;
            }
        }
        cout<<ans<<endl;
    }
}
1001
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

LL x;
int vis[1005];
int yes[1005];
int ans[]={1,7,10,13,19,23,28,31,32,44,49,68,70,79,82,86,91,94,97,100,103,109,129,130,133,139,167,176,188,190,192,193,203,208,219,226,230,236,239,262,263,280,291,293,301,302,310,313,319,320,326,329,331,338,356,362,365,367,368,376,379,383,386,391,392,397,404,409,440,446,464,469,478,487,490,496,536,556,563,565,566,608,617,622,623,632,635,637,638,644,649,653,655,656,665,671,673,680,683,694,700,709,716,736,739,748,761,763,784,790,793,802,806,818,820,833,836,847,860,863,874,881,888,899,901,904,907,910,912,913,921,923,931,932,937,940,946,964,970,973,989,998,1000};

void init()
{
    for(int i=0;ans[i]<1000;i++)
        yes[ans[i]]=1;
}

LL cal(LL x)
{
    LL ret=0;
    while(x)
    {
        ret+=(x%10)*(x%10);
        x/=10;
    }
    return ret;
}

bool ok(LL x)
{
    if(x<1000&&yes[x]==1)
    {
        return true;
    }
    if(x<1000&&vis[x]) return 0;
    if(x<1000) vis[x]=1;
    return ok(cal(x));
}

int main()
{
    init();
    while(cin>>x)
    {
        memset(vis,0,sizeof(vis));
        if(ok(x))
            puts("YES");
        else
            puts("NO");
    }
}
1004
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

long double x0,y0,x1,y1,v,vx,vy;    //用double wa了。。

struct point
{
    long double x,y;
    long double operator *(const point &rhs)const 
    {
        return x*rhs.x+y*rhs.y;
    }
}p0,p1,v0,p;

long double dist(point p)
{
    return sqrt(p.x*p.x+p.y*p.y); 
}

int main()
{
    int T;
    cin>>T;
    while(T--)
    {
        cin>>p0.x>>p0.y;
        cin>>p1.x>>p1.y;
        cin>>v0.x>>v0.y;
        cin>>v;
        p.x=p1.x-p0.x,p.y=p1.y-p0.y;
        long double v0_l=dist(v0);
        long double p_l=dist(p);
        
        if(v0*p<=0)
        {
            if(v>v0_l)
                puts("YES");
            else
                puts("NO");
        }
        else
        {
            long double v_in_d=v0*p/p_l;
            if(dist(v0)*dist(v0)-(v_in_d*v_in_d)<=v*v)
                puts("YES");
            else 
                puts("NO");
        }
    }
}
1007

 

转载于:https://www.cnblogs.com/Just--Do--It/p/6502048.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值