10.5 noip模拟试题

Posted 一入OI深似海

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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<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;
}
View Code

 

3

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

/*暴力*/
#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;
}
View Code

链表搞搞就很快了

#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;
}
View Code

 

思路题

#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;    
}
View Code

以上是关于10.5 noip模拟试题的主要内容,如果未能解决你的问题,请参考以下文章

noip模拟赛 写代码

[10.5模拟赛]T3

[10.5模拟赛]T1

NOIP模拟赛16

NOIp模拟赛binary

XJOI NOIP模拟题1