• ARC106


    A
    (quad)简单题,看清题意乱搞就可以了。

    code

    #include<iostream>
    #include<cstdio>
    #include<cstdlib>
    #include<cstring>
    #include<string>
    #include<algorithm>
    #include<cmath>
    #include<ctime>
    #include<climits>
    #include<sstream>
    #include<fstream>
    using namespace std;
    #define int long long
    
    signed main()
    {
        int n;
        cin >> n;
        int a = 3 , b = 5;
        int ca = 1 , cb = 1;
        while(b <= n)
        {
            cb++;
            b *= 5;
        }
        while(a <= n)
        {
            while(a + b > n && cb > 1)
            {
                cb--;
                b /= 5;
            }
            if(a + b == n)
            {
                cout << ca << " " << cb;
                return 0;
            }
            a *= 3;
            ca++;
            b *= 5;
            cb++;
        }
        cout << -1;
        return 0;
    }
    

    B
    (quad)考虑到一个连通块内的节点数值可以相互转移,所以用并查集弄弄就好了。

    code

    #include<iostream>
    #include<cstdio>
    #include<cstdlib>
    #include<cstring>
    #include<string>
    #include<algorithm>
    #include<cmath>
    #include<ctime>
    #include<climits>
    #include<sstream>
    #include<fstream>
    using namespace std;
    #define int long long
    
    const int N = 2e5 + 10;
    
    int fa[N];
    
    inline int find(int x)
    {
        if(x == fa[x])
        {
            return fa[x];
        }
        else
        {
            return fa[x] = find(fa[x]);
        }
    }
    
    inline void modify(int x , int y)
    {
        int p = find(x) , q = find(y);
        fa[p] = q;
    }
    
    int a[N] , b[N];
    int sa[N] , sb[N];
    
    signed main()
    {
        ios::sync_with_stdio(false);
        int n , m;
        cin >> n >> m;
        for(register int i = 1 ; i <= n ; i++)
        {
            cin >> a[i];
        }
        for(register int i = 1 ; i <= n ; i++)
        {
            cin >> b[i];
        }
        for(register int i = 1 ; i <= n ; i++)
        {
            fa[i] = i;
        }
        for(register int i = 1 ; i <= m ; i++)
        {
            int u , v;
            cin >> u >> v;
            modify(u , v);
        }
        for(register int i = 1 ; i <= n ; i++)
        {
            sa[find(i)] += a[i];
            sb[find(i)] += b[i];
        }
        for(register int i = 1 ; i <= n ; i++)
        {
            if(sa[i] != sb[i])
            {
                cout << "No";
                return 0;
            }
        }
        cout << "Yes";
        return 0;
    }
    

    C题题目太常生肉看不懂就走去搞其它的了。

    $——byquad wanwanjiuhao7744$
  • 相关阅读:
    js函数的属性和方法
    php中str_repeat函数
    html5中的空格符
    php实现简单算法3
    php intval函数
    什么是全栈工程师
    配置Log4j(非常具体)
    【解决】/usr/bin/ld: cannot find -lc
    Java的位运算符具体解释实例——与(&amp;)、非(~)、或(|)、异或(^)
    【小白的java成长系列】——顶级类Object源代码分析
  • 原文地址:https://www.cnblogs.com/wanwanjiuhao7744/p/15134990.html
Copyright © 2020-2023  润新知