Advertisement
Zeinab_Hamdy

Untitled

Jul 5th, 2023
1,126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.70 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define nl "\n"
  4. #define fi first
  5. #define se second
  6. #define pb push_back
  7. #define ll long long
  8. #define ull unsigned ll
  9. #define RV  return void
  10. #define inf 2000000000
  11. #define MOD ((ll) 1e9 + 7)
  12. #define sz(x) int(x.size())
  13. #define all(v) v.begin(), v.end()
  14. #define rall(v) v.rbegin(), v.rend()
  15. #define Mini(x) *min_element(all(x))
  16. #define Maxi(x) *max_element(all(x))
  17. #define fixed(n) fixed << setprecision(n)
  18. #define ceil(w, m) (((w) / (m)) + ((w) % (m) ? 1 : 0))
  19. #define cin(v) for (auto&i:v) cin >> i;
  20. #define cout(v) for (auto&i:v) cout << i << " ";
  21. #define clr(memo, x) memset(memo, x, sizeof memo)
  22. #define updmin(a, b) a = min(a, b)
  23. #define updmax(a, b) a = max(a, b)
  24. #define vi vector < int >
  25. #define vl vector < ll >
  26. #define vc vector < char >
  27. #define vs vector < string >
  28. #define v2i vector < vector < int > >
  29. #define v2l vector < vector < int > >
  30. #define seti set < int >
  31. #define setl set < ll >
  32. #define mapii map < int , int >
  33. #define mapll map < ll , ll >
  34. #define mapli map < ll , int >
  35. #define mapci map < char , int >
  36. #define mapsi map < string , int >
  37. #define pll pair < ll , ll >
  38. #define pii pair < int , int >
  39. #define range(l,r,x) for(int i=l ; i < r ; i+=x)
  40. #define FastCode ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  41. vector < string > ternary= {"NO\n" , "YES\n"};
  42.  
  43. void  Zainab(){
  44.             #ifndef ONLINE_JUDGE
  45.               freopen("input.txt", "r", stdin);  
  46.               freopen("output.txt", "w", stdout);
  47.             #endif
  48. }
  49.  
  50.  
  51. /*================================  Prblem solution  ================================ */
  52. const ll mod = (ll) (1e9+7);
  53.  
  54. ll mul(ll a , ll b , ll mod=MOD){
  55.     return ( (a % mod) * ( b % mod)) % mod ;
  56. }
  57.  
  58. ll BinEx(ll a , ll b , ll mod=MOD){
  59.     ll ret =1;
  60.     while(b){
  61.         if( b & 1 ) ret = mul(ret , a );
  62.  
  63.         a = mul(a ,a);
  64.         b>>=1;
  65.     }
  66.     return ret;
  67. }
  68.  
  69. ll inv(ll x){
  70.     return BinEx(x,MOD-2);
  71. }
  72. void myCode(){
  73.  
  74. int n ;
  75. cin >> n ;
  76.  
  77. ll num = 1 , sum =1   , N =1;
  78. // pro =  pow (n , num/2 )
  79. vector < pair < ll , ll >  > v (n);
  80. for(int i =0 ; i < n ; i++ ){
  81.     ll x , k;
  82.     cin >> x >> k;
  83.     v[i]={x,k};
  84.     num = mul(num , k+1 );
  85.     sum =mul ( sum , (BinEx(x , k+1 ) -1) * inv(x-1) );
  86. }
  87.  
  88. ll ans =1;
  89. for(auto& [x,k] : v){
  90.     ll temp = BinEx(k  , num/2 , mod-1);
  91.     ans = mul(ans , BinEx(x  , temp , mod));
  92. }
  93.  
  94.  
  95. cout << num << " " << sum  << " " <<  ans;
  96.  
  97. }
  98.  
  99.  
  100.  
  101.  
  102. int main(){
  103.                                    FastCode ;
  104.                                    Zainab() ;
  105.  
  106.     int testCase=1;
  107.         // cin >> testCase ;
  108.       for(int i=1 ; i<= testCase ; i++)
  109.         myCode();
  110.        
  111.     return 0;
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement