fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int mul(int r,int a,int n){
  5. return(r*1LL*a)%n;
  6. }
  7.  
  8. int main() {
  9. int a,b;
  10. int n=1e9+7;
  11. b=n-2;
  12. cin>>a;
  13. int r=1;
  14. while(b>0){
  15. if(b%2==1) r=mul(r,a,n);
  16. a=mul(a,a,n);
  17. b/=2;
  18. }
  19. cout<<r<<endl;
  20. return 0;
  21. }
Success #stdin #stdout 0s 4500KB
stdin
10
stdout
700000005