Translation of the meaning of problems
Seeking n-P ^ m O D value of m
Input Format
Line, is an integer of n, m, p (note the order)
Output Format
Line, for the n-P ^ m O D m value
the data shows
To 100% of the data 1 ≦ n, m≤10 ^. 9 . 1 ≤ n- , m ≤ . 1 0 . 9 1≤p≤10 ^ {14} . 1 ≤ P ≤ . 1 0 . 1 . 4
Translation Provider: Ryan WXN
https://www.luogu.org/problemnew/show/AT1357
Resolution:
This is the power of fast template title
#include<iostream> #include<cstdio> using namespace std; long long n,m,p; long long fast(long long a,long long n,long long p){ long long s=1; while(n){ if(n&1) s=(s*a)%p; a=(a*a)%p; n=n>>1; }; return s; } int main(){ CIN >> n-m >> >> P; COUT << FAST (n-, P, m) << endl; // output must be a carriage return, 0 otherwise return 0 ; }