标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)
Total Submission(s): 1308 Accepted Submission(s): 471
#include <stdio.h> #include <iostream> #include <algorithm> #include <string.h> #include<queue> using namespace std; #define INF 99999999 const int maxn =600; const int maxm =360000; const int oo = 1<<29; int f[11000000]; #define mod 1000000007 #define LL __int64 int find(int x) { while(x!=f[x])x=f[x]; return x; } LL mul(LL a,LL b) { if(b==0)return 1; if(b==1)return a; LL c=mul(a,b/2); c=(c*c)%mod; if(b&1)c=(c*a)%mod; return c; } int main() { int n,m,a,b,i; while(~scanf("%d%d",&n,&m)) { for(i=0;i<=n;i++)f[i]=i; LL ans=n; for(i=1;i<=m;i++) { scanf("%d%d",&a,&b); a=find(a-1); b=find(b); if(a==b)continue; f[b]=a; ans--; } cout<<mul(26,ans)<<endl; } return 0; }
标签:
原文地址:http://www.cnblogs.com/a972290869/p/4260064.html