2017-10-26 NOIP模拟赛
Posted Soda
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2017-10-26 NOIP模拟赛相关的知识,希望对你有一定的参考价值。
三分咲
#include<iostream> #include<cstdio> #include<ctime> using namespace std; int n,m,s; int main(){ //freopen("Cola.txt","r",stdin); freopen("three.in","r",stdin);freopen("three.out","w",stdout); scanf("%d%d",&n,&m); for(register int i=2;i<=n;++i){ s=s+m; while(s>=i)s-=i; } printf("%d",s+1); }
五分咲
#include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> using namespace std; double xs,ys,xt,yt,xa,ya,r,xb,yb,xc,yc,va,vb,vc; double A,B,C; void line(double m,double n,double p,double q){ A=n-q;B=-(m-p);C=q*m-p*n;//计算直线解析式 } double dis(double m,double n,double p,double q){ double res=sqrt((m-p)*(m-p)+(n-q)*(n-q));//两点之间距离 return res; } int main(){ //freopen("Cola.txt","r",stdin); freopen("five.in","r",stdin);freopen("five.out","w",stdout); scanf("%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf",&xs,&ys,&xt,&yt,&xa,&ya,&r,&xb,&yb,&xc,&yc,&va,&vb,&vc); if(xb>xc)swap(xb,xc),swap(yb,yc); line(xb,yb,xc,yc); if(va==vb&&va==0){ /*double d=fabs(A*xa+B*yb+C)/(sqrt(A*A+B*B)); if(d<=r){//直线与圆相交 double d1=dis(xa,ya,xb,yb); double d2=dis(xa,ya,xc,yc); double ans=min(d1,d2); if(ans<=r){puts("0.000");return 0;} ans-=r;printf("%.3lf",ans/vc);return 0; } double W=ya-(B*xa/A); double footx=(-A*C-W*A*B)/(B*B+A*A);//垂足的坐标 double footy=(W*A*A-C*B)/(B*B+A*A); if(footx>=xc){ double ans=dis(xa,ya,xc,yc); ans-=r; printf("%.3lf",ans/vc);return 0; } if(footx<=xb){ double ans=dis(xa,ya,xb,yb); ans-=r; printf("%.3lf",ans/vc);return 0; } if(footx<xc&&footx>xb){ double ans=d-r; printf("%.3lf",ans/vc);return 0; }*/ printf("%.3lf",dis(xs,ys,xt,yt)/vc);return 0; } if(r==0){ if(va==vb&&vb==vc){ double ans=dis(xs,ys,xt,yt)/va; printf("%.3lf",ans);return 0; } double lx=xb,rx=xc,ly=yb,ry=yc; double ans=1000000000; for(int i=1;i<=40;i++){ double midx1=(2*lx+rx)/3.0,midy1=(2*ly+ry)/3.0; double midx2=(2*rx+lx)/3.0,midy2=(2*ry+ly)/3.0; double ans1=dis(xs,ys,midx1,midy1)/vc+dis(midx1,midy1,xt,yt)/vb; double ans2=dis(xs,ys,midx2,midy2)/vc+dis(midx2,midy2,xt,yt)/vb; if(ans1<ans2)ans=ans1,rx=midx2,ry=midy2; else ans=ans2,lx=midx1,ly=midy1; } printf("%.3lf",ans);return 0; } printf("%.3lf",dis(xs,ys,xt,yt)/vc); }
八分咲
#include<iostream> #include<cstdio> using namespace std; int n,k,t,sum,x,y; bool flag=0; int main(){ freopen("eight.in","r",stdin);freopen("eight.out","w",stdout); scanf("%d%d%d",&n,&k,&t); for(int i=1;i<n;i++)scanf("%d%d",&x,&y); int z; for(int i=1;i<=n;i++){ scanf("%d%d",&x,&y); sum+=x; if(y>0)flag=1; for(int j=1;j<=y;j++){ scanf("%d%d",&x,&z); } } if(sum<71||flag==0){printf("%d",sum);return 0;} else puts("71"); }
以上是关于2017-10-26 NOIP模拟赛的主要内容,如果未能解决你的问题,请参考以下文章