fork download
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #pragma comment (linker, "/STACK:16777216")
  3. #include <algorithm>
  4. #include <numeric>
  5. #include <string>
  6. #include <string.h>
  7. #include <map>
  8. #include <set>
  9. #include <vector>
  10. #include <queue>
  11. #include <iostream>
  12. #include <fstream>
  13. #include <cmath>
  14. #include <math.h>
  15. #include <iomanip>
  16. #include <stdlib.h>
  17. #include <time.h>
  18. #include <sstream>
  19. #include <stdio.h>
  20. #include <stack>
  21. #include <time.h>
  22. #include <list>
  23. #include <iterator>
  24.  
  25. using namespace std;
  26.  
  27. #define FOR(i,n) for (int i=0; i<n; ++i)
  28. #define FORE(i,n) for (int i=0; i<=n; ++i)
  29. #define REP(i,a,b) for (int i=a; i<b; ++i)
  30. #define REPE(i,a,b) for (int i=a; i<=b; ++i)
  31. #define ALL(c) (c).begin(), (c).end()
  32. #define SORT(c) sort(ALL(c))
  33. #define mp make_pair
  34. #define pb push_back
  35. #define INF (1e9)
  36.  
  37. typedef pair<int, int> PII;
  38. typedef vector<PII> VPII;
  39. typedef long long int LL;
  40. typedef vector<int> VI;
  41. typedef vector<bool> VB;
  42. typedef vector<VI> VVI;
  43. const long double pi = 3.14159265358979323846;
  44. const int inf = (int)1e9;
  45. const LL llinf = (LL)1e18;
  46.  
  47. const int base = 10;
  48. double eps = 1e-9;
  49.  
  50. bool pred (const pair<PII,int>& i, const pair<PII,int>& j) {
  51. if (i.first.second == j.first.second) {
  52. return i.first.first < j.first.first;
  53. }
  54. return i.first.second < j.first.second;
  55. }
  56.  
  57. LL dp[30][30];
  58. int mod = inf + 7;
  59.  
  60. LL binpow(LL a, LL n) {
  61. LL res = 1;
  62. while(n) {
  63. if (n & 1) {
  64. res = (res * a) % mod;
  65. }
  66. a = (a * a) % mod;
  67. n >>= 1;
  68. }
  69. return res;
  70. }
  71.  
  72. int main(){
  73. #ifdef _DEBUG
  74. freopen("input.txt","r",stdin);
  75. freopen("output.txt","w",stdout);
  76. #else
  77. // freopen("input.txt","r",stdin);
  78. // freopen("output.txt","w",stdout);
  79. #endif
  80. dp[0][0] = 1;
  81. FORE(i,25) {
  82. FORE(j,25) {
  83. dp[i][j + 1] += dp[i][j];
  84. dp[i + 1][j] += dp[i][j];
  85. }
  86. }
  87. int a,b;
  88. cin >> a >> b;
  89. if (a > b) {
  90. swap(a,b);
  91. }
  92. if (b < 25) {
  93. cout << 0;
  94. return 0;
  95. }
  96. if (b > 25 && b - a != 2) {
  97. cout << 0;
  98. return 0;
  99. }
  100. if (b == 25 && a > 23) {
  101. cout << 0;
  102. return 0;
  103. }
  104. if (b <= 25) {
  105. cout << dp[a][b - 1] % mod;
  106. return 0;
  107. }
  108. int x = b - 26;
  109. LL now = dp[24][24] % mod;
  110. LL res = (binpow(2, x) * now) % mod;
  111. cout << res;
  112. return 0;
  113. }
  114.  
  115.  
Success #stdin #stdout 0s 3304KB
stdin
30 28
stdout
655317873