1353 The game of the Great Gods
time limit: 1 sspace limit: 128000 KBtitle level: Golden Gold SolvingTitle Description
Description
In that remote room, there is a magic lattice. For the sake of convenience, we are numbered 1~n. Legend has it that if you put some cards, you can achieve your wishes. The cards have a total of M colors, but the adjacent compartments cannot be placed in the same color card. By not repeating all the combinations, you can summon the Divine Burger @ To solve your great God and fulfill your dream. The SHC classmate who had turned out the records from the ancient books, he set up his card on the night. Now he wants to know how many different combinations are illegal in order to figure out the day the wish was fulfilled. But our SHC classmates are busy posing cards, and this task will be handed to you naturally.
Enter a description
Input Description
Enter a two integer m,n.
1<=m<=10^8,1<=n<=10^12
Output description
Output Description
Number of combinations, modulus 10086 take-up
Sample input
Sample Input
2 3
Sample output
Sample Output
6
Data range and Tips
Data Size & Hint
6 states of (000) (001) (011) (100) (110) (111)
60% of data n<=100 0000
God Burger is a famous sister, not black her XD
Category labels
Tags Click here to expandArithmetical
//Answer: (m^n-m* (m-1) ^ (n-1))%10086#include <cstdio>#include<iostream>using namespacestd;#defineMoD 10086Long LongM,n,p1,p2,ans;Long Longf[1001];/*Long Long Quick_pow (long long X,long long n) {if (n==0) return 1; else{while (!) ( n&1)) {n>>=1; X*=x; }} long long result=x; n>>=1; while (n) {x*=x; if ((n&1)) {result*=x; } n>>=1; } return result;*/Long LongQuick_pow (Long LongBLong LongA) {//Note: The fast power inside to take the remainder if(!a)return 1;//using the idea of dichotomy if(a&1)return(Quick_pow (b,a-1)%mod*b)%mod;//Odd Long LongT=quick_pow (b,a/2)%mod;//even return(t*t)%MoD;}intMain () {CIN>>m>>N; P1=quick_pow (m%mod,n)%mod;//Note that the power cannot be taken, because there is no such formulaP2=quick_pow (M-1)%mod, (n1)) *m%MoD; Ans= (p1-p2+mod*Ten)%MoD; cout<<ans<<Endl; return 0;}
1353 the game of the Great Gods