fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define mod 1000000007
  5. ll po(ll a, ll n)
  6. {
  7. ll res = a, ans = 1;
  8. while (n)
  9. {
  10. if (n % 2)
  11. ans = ans * res % mod;
  12. res = res * res % mod;
  13. n /= 2;
  14. }
  15. return ans;
  16. }
  17. int main()
  18. {
  19. ll n;
  20. cin >> n;
  21. cout << po(3, n - 1);
  22. return 0;
  23. }
Success #stdin #stdout 0s 4900KB
stdin
2
stdout
3