摘要:
该题为简单的并查集应用,只要按要求把给定的关系合并起来,并在合并时遴选出最佳个数即可。 代码如下:#include <cstdio>#include <cstring>#include <cstdlib>#include <cmath>using namespace std;int set[100005];int cnt[100005];int max;inline int find( int x ){ return set[x]= x == set[x]? x: find( set[x] );}inline void merge( int x, 阅读全文
摘要:
1602: GCD depthTime Limit:1 SecMemory Limit:128 MBSubmit:24Solved:3[Submit][Status][Web Board]DescriptionIn mathematics, the greatest common divisor (gcd), also known as the greatest common factor (gcf), or highest common factor (hcf), of two or more non-zero integers, is the largest positive intege 阅读全文