ARC111

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;
#include<vector>
#define int long long

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()
{
	int n , m;
	cin >> n >> m;
	cout << (pow(10 , n , m * m) / m) % m;
	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;

const int N = 4e5 + 10;

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;
}

bool xrq = 0;
int sum = 0;

int col[N] , cl;

inline void dfs(int u , int pre)
{
    sum++;
    col[u] = cl;
    for(register int i = head[u] ; i ; i = net[i])
    {
        int v = vis[i];
        if(i == (pre ^ 1))
        {
            continue;
        }
        if(col[v] == 0)
        {
            dfs(v , i);
        }
        else
        {
            xrq = 1;
        }
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    int n , m;
    cin >> m;
    n = 0;
    for(register int i = 1 ; i <= m ; i++)
    {
        int a , b;
        cin >> a >> b;
        add(a , b);
        add(b , a);
        n = max(n , max(a , b));
    }
    int ans = 0;
    for(register int i = 1 ; i <= n ; i++)
    {
        if(col[i] == 0)
        {
            xrq = 0;
            sum = 0;
            cl++;
            dfs(i , 0);
            if(xrq == 0)
            {
                ans += sum - 1;
            }
            else
            {
                ans += sum;
            }
        }
    }
    cout << ans;
    return 0;
}

\(\quad\)后面GGG了。

ARC111

上一篇:Redis的应用


下一篇:SMBMS②登录流程实现