Advertisement
Guest User

Untitled

a guest
Dec 11th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define F first
  3. #define S second
  4. #define pb push_back
  5. #define llong long long
  6. #define dlong long double
  7. #define endl '\n'
  8.  
  9. #pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")
  10.  
  11. using namespace std;
  12.  
  13. const int N=(1e5) + 5;
  14. const int MOD=(1e9) + 7;
  15.  
  16.  
  17. llong binpow (llong a, int n) {
  18. llong res = 1;
  19. while (n) {
  20. if (n & 1) res *= a;
  21. res%=MOD;
  22. a *= a;
  23. a%=MOD;
  24. n >>= 1;
  25. }
  26. return res%MOD;
  27. }
  28.  
  29. int main() {
  30. ios_base::sync_with_stdio();
  31. cin.tie(0);
  32. cout.tie(0);
  33. #ifdef LOCAL
  34. freopen("input.txt", "r", stdin);
  35. freopen("output.txt", "w", stdout);
  36. #else
  37. //freopen("input.txt", "r", stdin);
  38. //freopen("output.txt", "w", stdout);
  39. #endif // LOCAL
  40. int x,y;
  41. cin >> x >> y;
  42. if (y%x!=0){
  43. cout << 0 << endl;
  44. return 0;
  45. }
  46. int k=y/x;
  47. if (k==1){
  48. cout << 1 << endl;
  49. return 0;
  50. }
  51. cout << (binpow(2,k-1) - 1 + MOD )% MOD << endl;
  52. return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement