10.5 noip模拟试题

时间:2023-03-08 23:36:25
10.5 noip模拟试题

10.5 noip模拟试题

10.5 noip模拟试题

10.5 noip模拟试题

10.5 noip模拟试题

2bc*cosA=b^2+c^2-a^2

数学题QAQ

开始π精度不够40分 怪我喽~

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const double pi=3.14159265358979323846264;
int T;
double a,c,b,d,r1,r2,C,x,y,P,s;
double Abs(double r){
return r<?-r:r;
}
int main()
{
freopen("standing.in","r",stdin);
freopen("standing.out","w",stdout);
cin>>T;
while(T--){
cin>>a>>b>>r1>>c>>d>>r2;
x=sqrt((a-c)*(a-c)+(b-d)*(b-d));
double r=Abs(r1-r2);
if(x<=r){
if(r2>r1)r1=r2;
s=pi*r1*r1;
printf("%.3f\n",s);
continue;
}
if(x>=r1+r2){
s=pi*r1*r1+pi*r2*r2;
printf("%.3f\n",s);
continue;
}
y=(r1*r1+x*x-r2*r2)/(*x*r1);
P=acos(y)*;
s=P/(*pi)*pi*r1*r1-r1*r1*sin(P)/;
C=s;
y=(r2*r2+x*x-r1*r1)/(*x*r2);
P=acos(y)*;
s=P/(*pi)*pi*r2*r2-r2*r2*sin(P)/;
C+=s;
s=pi*r1*r1+pi*r2*r2;s-=C;
printf("%.3f\n",s);
}
return ;
}

10.5 noip模拟试题

3

10.5 noip模拟试题

暴力能过 考试的时候就没想正解

/*暴力*/
#include<iostream>
#include<cstdio>
#include<cstring>
#define maxn 100010
using namespace std;
int n,t,f[maxn],p;
int main()
{
freopen("resist.in","r",stdin);
freopen("resist.out","w",stdout);
scanf("%d%d",&n,&t);
if(n==){
printf("0\n");
return ;
}
p=;int m=n;
while(m){
int cnt=;
while(){
while(f[p]){p++;if(p==n+)p=;}
cnt++;
if(cnt==t){f[p]=;m--;break;}
p++;if(p==n+)p=;
}
}
printf("%d\n",p);
return ;
}

链表搞搞就很快了

#include<iostream>
#include<cstdio>
#include<cstring>
#define maxn 100010
using namespace std;
int n,t,c[maxn],p;
int main()
{
freopen("resist.in","r",stdin);
freopen("resist.out","w",stdout);
scanf("%d%d",&n,&t);
for(int i=;i<n;i++)
c[i]=i+;
c[n]=;
int cnt=;p=;
while(cnt<=n){
int tot=;
while(){
tot++;
if(tot==t-){
c[p]=c[c[p]];p=c[p];break;
}
p=c[p];
}
cnt++;
}
printf("%d\n",p);
return ;
}

10.5 noip模拟试题

10.5 noip模拟试题

思路题

#include<iostream>
#include<cstdio>
#include<cstring>
#define maxn 1010
using namespace std;
int n,m,x,mxl[maxn],mxc[maxn],mx,mi;
int f[maxn],c[maxn];
int init(){
int x=;char s=getchar();
while(s<''||s>'')s=getchar();
while(s>=''&&s<=''){x=x*+s-'';s=getchar();}
return x;
}
int main()
{
freopen("neighbor.in","r",stdin);
freopen("neighbor.out","w",stdout);
n=init();m=init();
for(int i=;i<=n;i++)mxl[i]=init();
for(int i=;i<=m;i++)mxc[i]=init();
for(int i=;i<=n;i++)
for(int j=;j<=m;j++)
mx+=min(mxl[i],mxc[j]);
for(int i=;i<=n;i++)f[mxl[i]]++;
for(int i=;i<=m;i++)c[mxc[i]]++;
for(int i=;i<=;i++)
mi+=max(f[i],c[i])*i;
printf("%d %d\n",mi,mx);
return ;
}