Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define F first
- #define S second
- #define pb push_back
- #define llong long long
- #define dlong long double
- #define endl '\n'
- #pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")
- using namespace std;
- const int N=(1e5) + 5;
- const int MOD=(1e9) + 7;
- llong binpow (llong a, int n) {
- llong res = 1;
- while (n) {
- if (n & 1) res *= a;
- res%=MOD;
- a *= a;
- a%=MOD;
- n >>= 1;
- }
- return res%MOD;
- }
- int main() {
- ios_base::sync_with_stdio();
- cin.tie(0);
- cout.tie(0);
- #ifdef LOCAL
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #else
- //freopen("input.txt", "r", stdin);
- //freopen("output.txt", "w", stdout);
- #endif // LOCAL
- int x,y;
- cin >> x >> y;
- if (y%x!=0){
- cout << 0 << endl;
- return 0;
- }
- int k=y/x;
- if (k==1){
- cout << 1 << endl;
- return 0;
- }
- cout << (binpow(2,k-1) - 1 + MOD )% MOD << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement