Advertisement
Norby9

Untitled

Jul 8th, 2020
1,050
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3.  
  4. #define ulli unsigned long long int
  5. #define modulo 1000000007
  6.  
  7. ifstream cin("rogvaiv.in");
  8. ofstream cout("rogvaiv.out");
  9.  
  10. ulli pow(ulli n, ulli putere) {
  11.     if(n == 1 || putere == 0) {
  12.         return 1;
  13.     }
  14.     if(putere == 1) {
  15.         return n;
  16.     }
  17.     if(putere % 2)
  18.         return 1LL * (n % modulo) * 1LL * (pow(n, putere - 1) % modulo);
  19.     return (1LL * pow(n, putere / 2) % modulo) * (1LL * pow(n, putere / 2) % modulo);
  20. }
  21.  
  22. int main(void) {
  23.     ulli num;
  24.     cin >> num;
  25.     num %= 1000000006;
  26.     cout << pow(7, num) % modulo;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement