试题+评测数据下载:https://yunpan.cn/cvKJgPjvrIKAJ (提取码:2d8e)
分析:
T1 模拟计算几何问题 难点主要是圆的相交问题
T2 约瑟夫环问题,模拟即可
T3 稍微想想就能过,maxans:尽量多填数;minans:尽量少填数(满足主视图&左视图的情况下)
2bc*cosA=b^2+c^2-a^2
3
T1
AC代码:
#include<cstdio> #include<cmath> #include<algorithm> using namespace std; const double PI=3.14159265358979323846264; struct node{ double x,y; double r; }a[2]; inline double getdis(node b,node c){ double xx=b.x-c.x; double yy=b.y-c.y; return sqrt(xx*xx+yy*yy); } void deal(node b,node c){ double len=getdis(b,c); if(len<=fabs(b.r-c.r)){ if(b.r<c.r) swap(b,c); double t1=PI*b.r*b.r; printf("%.3lf ",t1); return ; } double L=b.r+c.r; double t1=PI*b.r*b.r; double t2=PI*c.r*c.r; if(L<=len){ printf("%.3lf ",t1+t2); return ; } double ang1=acos((b.r*b.r+len*len-c.r*c.r)/2.0/b.r/len); double ang2=acos((c.r*c.r+len*len-b.r*b.r)/2.0/c.r/len); double ret=ang1*b.r*b.r+ang2*c.r*c.r-len*b.r*sin(ang1); printf("%.3lf ",t1+t2-ret); } int main(){ freopen("standing.in","r",stdin); freopen("standing.out","w",stdout); int T;scanf("%d",&T); while(T--){ scanf("%lf%lf%lf%lf%lf%lf",&a[0].x,&a[0].y,&a[0].r,&a[1].x,&a[1].y,&a[1].r); deal(a[0],a[1]); } return 0; }
T2
AC代码1:
#include<cstdio> #include<cstring> using namespace std; const int N=1e6+10; int n,t; bool vis[N]; void deal(int m){ int tot=n; int p=0; for(int i=1;tot>1;i++){ if(i>n) i=1; if(vis[i]) continue; if(++p==m) p=0,vis[i]=1,tot--; } for(int i=1;i<=n;i++) if(!vis[i]){printf("%d ",i);return ;} } int main(){ freopen("resist.in","r",stdin); freopen("resist.out","w",stdout); scanf("%d%d",&n,&t); deal(t); return 0; }
AC代码2:
#include<cstdio> using namespace std; int n,m,s; int main(){ freopen("resist.in","r",stdin); freopen("resist.out","w",stdout); scanf("%d%d",&n,&m); for(int i=2;i<=n;i++) s=(s+m)%i; printf("%d",s+1); return 0; }
T3
AC代码1:
#include<cstdio> #include<algorithm> using namespace std; const int N=1e3+10; int n,m,zhu[N],zuo[N],mp[N][N]; bool vis1[N],vis2[N]; int minans,maxans; void get_min(){ for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ if(!vis1[i]&&!vis2[j]&&zhu[i]==zuo[j]){ vis1[i]=vis2[j]=1; mp[i][j]=zhu[i]; } } } for(int i=1;i<=n;i++){ if(!vis1[i]){ for(int j=1;j<=m;j++){ if(!mp[i][j]&&zhu[i]<=zuo[j]){ mp[i][j]=zhu[i]; if(zhu[i]==zuo[j]) vis2[j]=1; break; } } } } for(int j=1;j<=m;j++){ if(!vis2[j]){ for(int i=1;i<=n;i++){ if(!mp[i][j]&&zuo[j]<=zhu[i]){ mp[i][j]=zuo[j];break; } } } } for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ minans+=mp[i][j]; } } } void get_max(){ for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ maxans+=min(zhu[i],zuo[j]); } } } int main(){ freopen("neighbor.in","r",stdin); freopen("neighbor.out","w",stdout); scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) scanf("%d",zhu+i); for(int i=1;i<=m;i++) scanf("%d",zuo+i); get_min(); get_max(); printf("%d %d",minans,maxans); return 0; }
AC代码2:
#include<iostream> #include<cstdio> #include<cstring> const int N=1e3+10; using namespace std; int n,m,zhu[N],zuo[N],maxans,minans; int f[N],c[N]; int main(){ freopen("neighbor.in","r",stdin); freopen("neighbor.out","w",stdout); scanf("%d%d",&n,&m); for(int i=1;i<=n;i++)scanf("%d",&zhu[i]); for(int i=1;i<=m;i++)scanf("%d",&zuo[i]); for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) maxans+=min(zhu[i],zuo[j]); for(int i=1;i<=n;i++)f[zhu[i]]++; for(int i=1;i<=m;i++)c[zuo[i]]++; for(int i=0;i<=1000;i++) minans+=max(f[i],c[i])*i; printf("%d %d ",minans,maxans); return 0; }