LuoguP6153 询问 题解

Content

\(n\) 个物品,标号为 \(1,2,3,...,n\)

\(m\) 个条件,每个条件的两个元素为 \(x,y\),代表第 \(x\) 个物品和第 \(y\) 个物品是相同的。

请根据 \(m\) 个条件算出这 \(n\) 个物品有多少不同的种类。

数据范围:\(1\leqslant n\leqslant10^{18}\)\(1\leqslant m\leqslant 10^7\)

Solution

根据题目可知,条件一定不会重复,所以这道题目退化成了一个纯粹的 \(\texttt{a-b~problem(非高精)}\)

Code

#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;

long long n, m, x, y;

int main() {
	scanf("%lld%lld", &n, &m);
	printf("%lld", n - m);
    return 0;
}
posted @ 2021-12-23 20:49  Eason_AC  阅读(78)  评论(0)    收藏  举报