zoukankan      html  css  js  c++  java
  • QFNU-ACM 2020.4.11 组队赛 (2020-4-11)

    D - A Simple Math Problem

    解题思路:给定两个正整数a和b,求出满足条件的合适的X和Y: X + Y =a最小公倍数(X, Y) =b

    数学不好的我留下了泪水qwq,大概就是gcd(x,y)==gcd(a,b),得x*y=gcd(a,b)*b;与x+y=a联立,解得

    AC代码:

    #include<cmath>
    #include<cstdio>
    #include<algorithm>
    #include<string>
    #include<vector>
    #include<iomanip>
    #include<iostream>
    using namespace std;
    typedef long long ll;
    int gcd(int a,int b)
    {
        if(b==0)
            return a;
        else
            return gcd(b,a%b);
    }
    int main()
    {
        int a,b,x,y,k1,k2,m,d;
        while(cin>>a>>b)
        {
            m=gcd(a,b);
            d=a*a-4*m*b;
            if(d<0)
            {
                cout<<"No Solution"<<endl;
            }
            else
            {
                int d1=sqrt(d);
                if(d1*d1!=d)
                {
                    cout<<"No Solution"<<endl;
                }
                else
                {
                    x=(a-d1)/2;
                    y=(a+d1)/2;
                    cout<<x<<' '<<y<<endl;
                }
            }
        }
        return 0;
    }

    H - To begin or not to begin

    思路:只有一个黑球的时候,谁先抽概率都一样,其余情况,先抽的人赢的概率大

    AC代码:

    #include<iostream>
    #include<cstdio>
    #include<cmath>
    #include<cstring>
    using namespace std;
    int main(){
           int k;
        while(cin>>k){
            if(k&1){
                cout<<"0"<<endl;
            }else{
                cout<<"1"<<endl;
            }
        }
        return 0;
    }

    I - Convex

    解题思路:化成一个一个三角形,根据面积S=1/2 A*B*sinC

    AC代码:

    #include<cmath>
    #include<cstdio>
    #include<algorithm>
    #include<string>
    #include<vector>
    #include<iomanip>
    #include<iostream>
    using namespace std;
    typedef long long ll;
    int main()
    {
        int n,m,x,y,i;
        double a[10];
        while(cin>>n>>m)
        {   double sum=0;
            for(i=0;i<n;i++){
                cin>>a[i];
                a[i]=a[i]*3.1415926/180;
                double b=sin(a[i]);
                sum+=b*m*m/2;
            }
            printf("%.3f
    ",sum);
        }
        return 0;
    }

    J - Find Small A

    解题思路:众所周知,字符a的ASCII码是97。现在,找出一组给定的数字中有多少个字母“a”。请注意,这里的数字是由计算机中的32位整数给出的。也就是说,1位代表4个字符(一个字符由8位的二进制数字表示)。

    #include<iostream>
    #include<cstdio>
    #include<cmath>
    #include<cstring>
    using namespace std;
    int main(){
        int n;
        long long num;
        while(cin>>n){
            long long counts=0;
            while(n--){
                cin>>num;
                while(num){
                    if(num%256==97)
                    counts++;
                    num=num/256;
                }
            }
            cout<<counts<<endl;
        }
          return 0;
    }
  • 相关阅读:
    hdu 5723 Abandoned country 最小生成树 期望
    OpenJ_POJ C16G Challenge Your Template 迪杰斯特拉
    OpenJ_POJ C16D Extracurricular Sports 打表找规律
    OpenJ_POJ C16B Robot Game 打表找规律
    CCCC 成都信息工程大学游记
    UVALive 6893 The Big Painting hash
    UVALive 6889 City Park 并查集
    UVALive 6888 Ricochet Robots bfs
    UVALive 6886 Golf Bot FFT
    UVALive 6885 Flowery Trails 最短路
  • 原文地址:https://www.cnblogs.com/a-specter/p/12722814.html
Copyright © 2011-2022 走看看