fork(25) download
  1. #include <cstdio>
  2. using namespace std;
  3.  
  4. int n, m, fa[100], x, y;
  5.  
  6. int gf(int x) {
  7. if (fa[x] != x) fa[x] = gf(fa[x]);
  8. return fa[x];
  9. }
  10.  
  11. int main() {
  12. scanf("%d%d", &n, &m);
  13. for (int i = 1; i <= n; i++) fa[i] = i;
  14. while (m--) {
  15. scanf("%d%d", &x, &y);
  16. fa[gf(x)] = gf(y);
  17. }
  18. long long ans = (1LL << n);
  19. for (int i = 1; i <= n; i++)
  20. if (gf(i) == i) ans /= 2;
  21. printf("%I64d\n", ans);
  22. }
  23.  
Success #stdin #stdout 0s 3300KB
stdin
Standard input is empty
stdout
                                                               1