zoukankan      html  css  js  c++  java
  • 2012 jinhua

    2012 jinhua

    I题:签到题,没什么意思。

    #include<iostream>
    #include<cstdio>
    #include<cstdlib>
    #include<algorithm>
    #include<cstdlib>
    
    using namespace std;
    
    const int maxn=1000100;
    
    int n;
    int a[maxn];
    
    int main()
    {
        while(cin>>n&&n){
            int ans=0;
            for(int i=1;i<=n;i++){
                scanf("%d",&a[i]);
                ans+=a[i]*a[i];
            }
            cout<<ans<<endl;
        }
        return 0;
    }
    View Code

    J题:排列组合水题。

    #include<iostream>
    #include<cstdio>
    #include<cstdlib>
    #include<algorithm>
    #include<cstring>
    
    using namespace std;
    
    const int maxn=1100;
    
    typedef long long ll;
    ll N,M,K;
    ll P;
    ll L[maxn],R[maxn];
    char s[30];int x;
    char t[30];int y;
    bool visL[maxn][maxn],visR[maxn][maxn];
    
    int main()
    {
       // freopen("in.txt","r",stdin);
        while(cin>>N>>M>>K){
            if(N==0&M==0&K==0) break;
            cin>>P;
            memset(L,0,sizeof(L));
            memset(R,0,sizeof(R));
            memset(visL,0,sizeof(visL));
            memset(visR,0,sizeof(visR));
            while(P--){
                scanf("%s%d%s%d",s,&x,t,&y);
                if(t[0]=='p'&&!visL[x][y]) L[y]++,visL[x][y]=1;
                else if(!visR[x][y]) R[x]++,visR[x][y]=1;
            }
            ll cnt=0;
            for(int i=1;i<=M;i++){
                cnt+=L[i]*K+N*R[i]-L[i]*R[i];
            }
            cout<<N*M*K-cnt<<endl;
        }
        return 0;
    }
    View Code

    A题:贪心。先比较两个的情况,推出贪心的依据,然后直接排序。

    #include<iostream>
    #include<cstdio>
    #include<cstdlib>
    #include<algorithm>
    #include<cstdlib>
    
    using namespace std;
    
    const int maxn=1000100;
    
    typedef long long ll;
    int n;
    const ll MOD=365*24*60*60;
    struct NOde
    {
        ll a,b;
        friend bool operator<(NOde A,NOde B)
        {
            return A.a*1.0*B.b<A.b*1.0*B.a;
        }
    };
    NOde Node[maxn];
    
    int main()
    {
       // freopen("in.txt","r",stdin);
        while(cin>>n&&n){
            for(int i=1;i<=n;i++){
                scanf("%lld%lld",&Node[i].a,&Node[i].b);
            }
            sort(Node+1,Node+n+1);
            ll res=0;
            for(int i=1;i<=n;i++){
                res=(res%MOD+((Node[i].a%MOD)+(Node[i].b%MOD)*(res%MOD))%MOD)%MOD;
            }
            cout<<res<<endl;
        }
        return 0;
    }
    View Code

    D题:傻逼物理题。枚举角度,注意枚举的精度,少开变量,在纸上算出最终结果再写代码。

    #include<iostream>
    #include<cstdio>
    #include<cstdlib>
    #include<algorithm>
    #include<cstring>
    #include<math.h>
    
    using namespace std;
    
    const int maxn=1100;
    const double Pi=acos(-1.0);
    const double g=9.8;
    const double EPS=0.0000000001;
    
    typedef long long ll;
    
    int N;
    double H,L1,R1,L2,R2;
    double v[maxn];
    
    int main()
    {
        //freopen("in.txt","r",stdin);
        while(cin>>N&&N){
            cin>>H>>L1>>R1>>L2>>R2;
            for(int i=1;i<=N;i++) scanf("%lf",&v[i]);
            int ans=0;
            for(double a=0;a<=Pi/2;a+=0.0002){
                int cnt=0;
                for(int i=1;i<=N;i++){
                    double x=v[i]*cos(a)*(v[i]*sin(a)+sqrt(v[i]*v[i]*sin(a)*sin(a)+2*g*H))/g;
                    if(x>L2-EPS&&x<R2+EPS){
                        cnt=0;break;
                    }
                    if(x>L1-EPS&&x<R1+EPS) cnt++;
                }
                ans=max(cnt,ans);
            }
            for(double a=0;a<=Pi/2;a+=0.0002){
                int cnt=0;
                for(int i=1;i<=N;i++){
                    double x=v[i]*cos(a)*(-v[i]*sin(a)+sqrt(v[i]*v[i]*sin(a)*sin(a)+2*g*H))/g;
                    if(x>L2-EPS&&x<R2+EPS){
                        cnt=0;break;
                    }
                    if(x>L1-EPS&&x<R1+EPS) cnt++;
                }
                ans=max(cnt,ans);
            }
            cout<<ans<<endl;
        }
        return 0;
    }
    View Code

    K题:傻逼模拟。

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<cstdlib>
    #include<algorithm>
    
    using namespace std;
    
    const int maxn=1000100;
    
    int N;
    int x1,y1,x2,y2;
    char d1,d2;
    int s1,s2;
    int t1,t2;
    int K;
    
    int goX(int x,char &dir,int s)
    {
        if(dir=='S'){
            x=x+s;
            if(x>N){
                int c=x-N;
                int t=c/N;
                c%=N;
                if(t&1) x=c+1;
                else x=N-c,dir='N';
            }
            return x;
        }
        if(dir=='N'){
            x=x-s;
            if(x<1){
                int c=1-x;
                int t=c/N;
                c%=N;
                if(t&1) x=N-c;
                else x=c+1,dir='S';
            }
            return x;
        }
        return x;
    }
    
    int goY(int y,char &dir,int s)
    {
        if(dir=='E'){
            y=y+s;
            if(y>N){
                int c=y-N;
                int t=c/N;
                c%=N;
                if(t&1) y=c+1;
                else y=N-c,dir='W';
            }
            return y;
        }
        if(dir=='W'){
            y=y-s;
            if(y<1){
                int c=1-y;
                int t=c/N;
                c%=N;
                if(t&1) y=N-c;
                else y=c+1,dir='E';
            }
            return y;
        }
        return y;
    }
    
    char Next(char dir)
    {
        if(dir=='E') return 'N';
        if(dir=='N') return 'W';
        if(dir=='W') return 'S';
        if(dir=='S') return 'E';
    }
    
    int main()
    {
        //freopen("in.txt","r",stdin);
        while(cin>>N&&N){
            x1=y1=1;x2=y2=N;
            cin>>d1>>s1>>t1>>d2>>s2>>t2;
            cin>>K;
            int t=1;
            for(int i=1;i<=K;i++){
                //cout<<d1<<" "<<d2<<endl;
                x1=goX(x1,d1,s1);
                y1=goY(y1,d1,s1);
                x2=goX(x2,d2,s2);
                y2=goY(y2,d2,s2);
                //cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<" "<<d1<<" "<<d2<<endl;
                if(x1==x2&&y1==y2){
                    swap(d1,d2);
                    continue;
                }
                if(t%t1==0) d1=Next(d1);
                if(t%t2==0) d2=Next(d2);
                t++;
            }
            cout<<x1<<" "<<y1<<endl;
            cout<<x2<<" "<<y2<<endl;
        }
        return 0;
    }
    View Code
    没有AC不了的题,只有不努力的ACMER!
  • 相关阅读:
    27 树莓派做直播平台
    1 视频压缩软件
    (9-4 )deepsort在ubuntu1604下配置
    利用mvn进行多环境配置
    fidder及Charles使用
    轻松搞定面试中的二叉树题目(java&python)
    数据结构与算法系列 目录
    [转]揭秘webdriver实现原理
    作用域安全的构造函数
    JavaScript函数绑定
  • 原文地址:https://www.cnblogs.com/--560/p/4753039.html
Copyright © 2011-2022 走看看