fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define file "o"
  5. #define ff(i, a, b) for(auto i=(a); i<=(b); ++i)
  6. #define ffr(i, b, a) for(auto i=(b); i>=(a); --i)
  7. #define nl "\n"
  8. #define ss " "
  9. #define pb emplace_back
  10. #define fi first
  11. #define se second
  12. #define sz(s) (int)s.size()
  13. #define all(s) (s).begin(), (s).end()
  14. #define ms(a,x) memset(a, x, sizeof (a))
  15. #define cn continue
  16. #define re exit(0)
  17.  
  18. typedef long long ll;
  19. typedef unsigned long long ull;
  20. typedef long double ld;
  21. typedef vector<int> vi;
  22. typedef vector<ll> vll;
  23. typedef pair<int, int> pii;
  24. typedef pair<ll, ll> pll;
  25. typedef vector<pii> vpii;
  26. typedef vector<pll> vpll;
  27.  
  28. mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
  29. ll ran(ll l, ll r)
  30. {
  31. return uniform_int_distribution<ll> (l, r)(rng);
  32. }
  33.  
  34. inline void rf()
  35. {
  36. ios_base::sync_with_stdio(false);
  37. cin.tie(nullptr); cout.tie(nullptr);
  38. if(fopen(file".inp","r"))
  39. {
  40. freopen(file".inp","r",stdin);
  41. freopen(file".out","w",stdout);
  42. }
  43. }
  44.  
  45. const int mod=1e9+7;
  46. const int maxn=3e5+15;
  47. const ll inf=1e16;
  48.  
  49. template<typename T> inline void add(T &x, const T &y)
  50. {
  51. x+=y;
  52. if(x>=mod) x-=mod;
  53. if(x<0) x+=mod;
  54. }
  55.  
  56. template<typename T> inline bool maxi(T &a, T b)
  57. {
  58. if(a>=b) return 0;
  59. a=b; return 1;
  60. }
  61.  
  62. template<typename T> inline bool mini(T &a, T b)
  63. {
  64. if(a<=b) return 0;
  65. a=b; return 1;
  66. }
  67.  
  68. using i128=__int128_t;
  69. ll n, m, modulo;
  70.  
  71. inline ll bpow(ll a, ll b, ll m)
  72. {
  73. a%=mod;
  74. ll ans=1;
  75. while(b)
  76. {
  77. if(b&1) ans=(i128)ans*(i128)a%m;
  78. a=(i128)a*(i128)a%m;
  79. b>>=1;
  80. }
  81. return ans;
  82. }
  83.  
  84. signed main()
  85. {
  86. rf();
  87. cin>>n>>m>>modulo;
  88. ll k=n*m, p=bpow(2, k+2, modulo);
  89. ll tmp=(k-1)%modulo, tmp2=(p+modulo-(4%modulo));
  90. ll ans=(i128)tmp*(i128)tmp2%modulo;
  91. cout<<ans;
  92. re;
  93. }
  94.  
Success #stdin #stdout 0s 5308KB
stdin
2 2 17
stdout
10