2bc*cosA=b^2+c^2-a^2
数学题QAQ
开始π精度不够40分 怪我喽~
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
#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<0?-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)/(2*x*r1); P=acos(y)*2; s=P/(2*pi)*pi*r1*r1-r1*r1*sin(P)/2; C=s; y=(r2*r2+x*x-r1*r1)/(2*x*r2); P=acos(y)*2; s=P/(2*pi)*pi*r2*r2-r2*r2*sin(P)/2; C+=s; s=pi*r1*r1+pi*r2*r2;s-=C; printf("%.3f\n",s); } return 0; }
3
暴力能过 考试的时候就没想正解
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
/*暴力*/ #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==0){ printf("0\n"); return 0; } p=1;int m=n; while(m){ int cnt=0; while(1){ while(f[p]){p++;if(p==n+1)p=1;} cnt++; if(cnt==t){f[p]=1;m--;break;} p++;if(p==n+1)p=1; } } printf("%d\n",p); return 0; }
链表搞搞就很快了
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
#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=1;i<n;i++) c[i]=i+1; c[n]=1; int cnt=0;p=1; while(cnt<=n){ int tot=0; while(1){ tot++; if(tot==t-1){ c[p]=c[c[p]];p=c[p];break; } p=c[p]; } cnt++; } printf("%d\n",p); return 0; }
思路题
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
#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=0;char s=getchar(); while(s<'0'||s>'9')s=getchar(); while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();} return x; } int main() { freopen("neighbor.in","r",stdin); freopen("neighbor.out","w",stdout); n=init();m=init(); for(int i=1;i<=n;i++)mxl[i]=init(); for(int i=1;i<=m;i++)mxc[i]=init(); for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) mx+=min(mxl[i],mxc[j]); for(int i=1;i<=n;i++)f[mxl[i]]++; for(int i=1;i<=m;i++)c[mxc[i]]++; for(int i=0;i<=1000;i++) mi+=max(f[i],c[i])*i; printf("%d %d\n",mi,mx); return 0; }