Code Lock
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)
Total Submission(s): 2029 Accepted Submission(s): 783
Problem Description
A lock you use has a code systemto be opened instead ofa key. The lock containsa sequence of wheels. Each wheel has the26 letters ofthe English alphabet 'a' through 'z', in order. If you move a wheel up, the letter it shows changes tothe next letter inthe English alphabet (ifit was showing thelast letter 'z', thenit 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 eachofthe wheels up withinthe subsequence.
If a lock can change to another aftera sequence of operations, we regard them as same lock. Find out how many different locks exist?
Input
There are several test cases inthe input.
Each test case begin withtwo integers N (1<=N<=10000000) and M (0<=M<=1000) indicating thelengthofthe code systemandthenumberof legal operations.
Then M lines follows. Each linecontainstwointeger L and R (1<=L<=R<=N), means an interval [L, R], eachtime you can choose one interval, move all ofthe wheels in this interval up.
The input terminates byendoffilemarker.
Output
For each test case, output the answer mod1000000007
Sample Input
11112112
Sample Output
126
Author
hanshuai
Code LockTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 2029 Accepted Submission(s): 783Problem DescriptionA lock you use has a code syst