• ARC114


    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
    
    const int N = 51;
    
    bool book[N];
    int p[N] , tot;
    
    inline void build()
    {
        book[0] = book[1] = 1;
        int n = 50;
        for(register int i = 2 ; i <= n ; i++)
        {
            if(book[i] == 0)
            {
                tot++;
                p[tot] = i;
            }
            for(register int j = 1 ; j <= tot && p[j] * i <= n ; j++)
            {
                book[p[j] * i] = 1;
                if(i % p[j] == 0)
                {
                    break;
                }
            }
        }
    }
    
    int x[N];
    
    inline int gcd(int a , int b)
    {
        if(b == 0)
        {
            return a;
        }
        else
        {
            return gcd(b , a % b);
        }
    }
    
    signed main()
    {
        ios::sync_with_stdio(false);
        int n;
        cin >> n;
        build();
        for(register int i = 1 ; i <= n ; i++)
        {
            cin >> x[i];
        }
        int ans = INT64_MAX;
        for(register int S = 0 ; S < (1 << tot) ; S++)
        {
            int res = 1;
            for(register int i = 0 ; i < tot ; i++)
            {
                if((S >> i) & 1)
                {
                    res *= p[i + 1];
                }
            }
            bool zzz = 1;
            for(register int i = 1 ; i <= n ; i++)
            {
                if(gcd(x[i] , res) == 1)
                {
                    zzz = 0;
                    break;
                }
            }
            if(zzz)
            {
                ans = min(ans , res);
            }
        }
        cout << ans;
        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;
    const int Mod = 998244353;
    
    int f[N];
    
    int head[N] , net[N] , vis[N];
    int tot = 1;
    
    inline void add(int u , int v)
    {
        tot++;
        net[tot] = head[u];
        head[u] = tot;
        vis[tot] = v;
    }
    
    int num = 0;
    
    int col[N] , cl;
    
    inline void dfs(int u)
    {
        col[u] = cl;
        for(register int i = head[u] ; i ; i = net[i])
        {
            int v = vis[i];
            if(col[v] == cl)
            {
                num++;
                return;
            }
            if(col[v] != 0)
            {
                return;
            }
            dfs(v);
        }
    }
    
    inline int pow(int a , int b , int c)
    {
        int ans = 1;
        while(b)
        {
            if(b & 1)
            {
                ans *= a;
                ans %= c;
            }
            a *= a;
            a %= c;
            b >>= 1;
        }
        return ans;
    }
    
    signed main()
    {
        ios::sync_with_stdio(false);
        int n;
        cin >> n;
        for(register int i = 1 ; i <= n ; i++)
        {
            cin >> f[i];
            add(i , f[i]);
        }
        for(register int i = 1 ; i <= n ; i++)
        {
            if(col[i] == 0)
            {
                cl++;
                dfs(i);
            }
        }
        cout << ((pow(2 , num , Mod) - 1) % Mod + Mod) % Mod;
        return 0;
    }
    

    后面的GGG了。

    $——byquad wanwanjiuhao7744$
  • 相关阅读:
    Android SD卡读写文件
    Android 是什么
    Canvas 类
    Java IO流之字节流 FileInputStream
    Android中asset文件夹和raw文件夹区别
    随手收藏
    Java IO流
    Android私有文件资源文件的存取
    ubuntu 下的jdk安装
    Paint类
  • 原文地址:https://www.cnblogs.com/wanwanjiuhao7744/p/15100904.html
Copyright © 2020-2023  润新知