# HDU 3461 Code Lock

Source: Internet
Author: User

`1#include <iostream>2#include <cstdio>3#include <cstdlib>4#include <cstring>5#include <string>6#include <queue>7#include <algorithm>8#include <map>9#include <iomanip>Ten#include <climits> One#include <string.h> A#include <numeric> -#include <cmath> -#include <stdlib.h> the#include <vector> -#include <stack> -#include <Set> - #defineFor (x, B, E) for (int x=b;x<= (e); x + +) + #defineREP (x, N) for (int x=0;x< (n); x + +) - #defineMAXN 100010 + #defineMAXN 1000010 A #defineMod 1000007 at #defineN 1010 - using namespacestd; -typedefLong LongLL; -  - intN, M; - inteax10000010]; in intCNT; -  to intFindset (intx) + { -     returnFA[X] = fa[x] = = x?X:findset (fa[x]); the } *  \$ voidMergeintAintb)Panax Notoginseng { -     intx =Findset (a); the     inty =Findset (b); +     if(X! =y) { AFA[X] =y; thecnt++; +     } - } \$  \$LL Quick_pow (intN) - { -LL tmp = -, sum =1; the      while(n) { -         if(N &1) sum = (SUM * tmp)%1000000007; WuyiTMP = (TMP * tmp)%1000000007; theN >>=1; -     } Wu     returnSum%1000000007; - } About  \$ intMain () - { -     intL, R; -      while(Cin >> N >>m) { ACNT =0; +for (I,0, n) fa[i] =i; thefor (I,1, M) { -CIN >> L >>R; \$Merge (L-1, R); the         } thecout << Quick_pow (n-cnt) <<Endl; the     } the     return 0; -}`

HDU 3461 Code Lock

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.