玲珑杯 Round #11 (1001 1004 1007)

时间:2023-03-08 23:56:14
玲珑杯 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=;i*i<=n;i++) if(n%i==)
{
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[];
int yes[];
int ans[]={,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,}; void init()
{
for(int i=;ans[i]<;i++)
yes[ans[i]]=;
} LL cal(LL x)
{
LL ret=;
while(x)
{
ret+=(x%)*(x%);
x/=;
}
return ret;
} bool ok(LL x)
{
if(x<&&yes[x]==)
{
return true;
}
if(x<&&vis[x]) return ;
if(x<) vis[x]=;
return ok(cal(x));
} int main()
{
init();
while(cin>>x)
{
memset(vis,,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<=)
{
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