Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define task "BITWEIGHT"
- #include <iostream>
- #include <cstdio>
- using namespace std;
- using ll = long long;
- using ld = long double;
- constexpr int N = 1e5 + 5;
- constexpr int mod = 1e9 + 7;
- string s;
- ll n;
- ll m;
- void Read()
- {
- cin >> s;
- }
- ll Pow(ll a, ll b)
- {
- ll ans(1);
- for (; b; b >>= 1)
- {
- if (b & 1)
- ans = ans * a % mod;
- a = a * a % mod;
- }
- return ans;
- }
- void Solve()
- {
- n = 0;
- m = 0;
- for (auto i : s)
- {
- n = (n * 10 + i - '0') % (mod - 1);
- m = (m * 10 + i - '0') % mod;
- }
- cout << Pow(2, (n - 1 + mod - 1) % (mod -1)) * m % mod << "\n";
- }
- int32_t main()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- if (fopen(task ".INP", "r"))
- {
- freopen(task ".INP", "r", stdin);
- freopen(task ".OUT", "w", stdout);
- }
- int t;
- for (cin >> t; t--;)
- {
- Read();
- Solve();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement