A lock you use has a code system to be opened instead of a key. The lock contains a sequence of wheels. Each wheel has the 26 letters of the English alphabet 'a' through 'z', in order. If you move a wheel up, the letter it shows changes to the next letter in the English alphabet (if it was showing the last letter 'z', then it changes to 'a'). 
At each operation, you are only allowed to move some specific subsequence of contiguous wheels up. This has the same effect of moving each of the wheels up within the subsequence. 
If a lock can change to another after a sequence of operations, we regard them as same lock. Find out how many different locks exist? 

InputThere are several test cases in the input.

Each test case begin with two integers N (1<=N<=10000000) and M (0<=M<=1000) indicating the length of the code system and the number of legal operations. 
Then M lines follows. Each line contains two integer L and R (1<=L<=R<=N), means an interval [L, R], each time you can choose one interval, move all of the wheels in this interval up.

The input terminates by end of file marker. 
OutputFor each test case, output the answer mod 1000000007Sample Input

1 1
1 1
2 1
1 2

Sample Output

1
26 题解:先放一放
 #include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#include <queue>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll gcd(ll a,ll b){
return b?gcd(b,a%b):a;
}
bool cmp(int x,int y)
{
return x>y;
}
const int N=;
const int mod=1e9+;
int f[N];
int find1(int x) {return x==f[x]?x:f[x]=find1(f[x]);};
int Union(int x,int y)
{
x=find1(x),y=find1(y);
if(x==y) return ;
return f[x]=y,;
}
ll multi(int x)
{
ll ans=,tmp=;
while(x){
if(x&) ans=(ans*tmp)%mod;
tmp=(tmp*tmp)%mod;
x>>=;
}
return ans;
}
int main()
{
int n,m;
while(~scanf("%d%d",&n,&m)){
for(int i=;i<=n+;i++) f[i]=i;
int a,b,ans=;
for(int i=;i<m;i++){
scanf("%d%d",&a,&b);
ans+=Union(a,b+);
}
printf("%lld\n",power(n-ans));
}
return ;
}

最新文章

  1. 多值(in),范围值(between..and)
  2. Java实现Mysql数据库自动备份
  3. php请求返回GeoJSON格式的数据
  4. java实现二叉树查找树
  5. [原]Android官方图片加载利器BitmapFun解析
  6. LCD参数解释及计算【转】
  7. oracle自定义job名字,job调度
  8. Protege A DOT error has occurred错误
  9. Hooks——钩子概览
  10. oracle 11g 安装及网络配置
  11. 栈的讲解 和 栈的生长方向 源代码技巧分析,简直没SEI 啦
  12. 使用python/casperjs编写终极爬虫-客户端App的抓取-ZOL技术频道
  13. MLC固态硬盘,与入量是3000次P/E
  14. 【转】100行代码实现最简单的基于FFMPEG+SDL的视频播放器
  15. js 常用正则表达式表单验证代码
  16. LR socket协议脚本
  17. IE低版本 JSON.parse 和stringify 的兼容 (IE8以下)
  18. Netty 系列三(ByteBuf).
  19. Code signing is required for product type &#39;Application&#39; in SDK &#39;iOS 11.4&#39;
  20. wamp 进入到项目中找不到localhost

热门文章

  1. SQL SERVER 2016研究四
  2. cnpm与npm的区别
  3. sap 类的左侧导航栏
  4. Scala集合(二)
  5. [py]python写一个通讯录step by step V3.0
  6. nginx的访问控制
  7. 请求&amp;注解
  8. 【Python】-NO.99.Note.4.Python -【Python3 条件语句 循环语句】
  9. [LeetCode] 130. Surrounded Regions_Medium tag: DFS/BFS
  10. SmartGit 过期破解 - 授权文件 Free Trial License to Non-Commercial