fork download
  1. #include <bits/stdc++.h>
  2.  
  3. typedef long double ld;
  4. #define int long long
  5.  
  6. #define gcd __gcd
  7. #define endl "\n"
  8. #define setbits(x) __builtin_popcountll(x)
  9. #define zrobits(x) __builtin_ctzll(x)
  10. #define mod 1000000007
  11. #define mod2 998244353
  12. #define maxe *max_element
  13. #define mine *min_element
  14. #define inf 1e18
  15. #define pb push_back
  16. #define all(x) x.begin(), x.end()
  17. #define f first
  18. #define s second
  19. #define lb lower_bound
  20. #define ub upper_bound
  21. #define ins insert
  22. #define sz(x) (int)(x).size()
  23. #define mk make_pair
  24. #define deci(x, y) fixed<<setprecision(y)<<x
  25. #define w(t) int t; cin>>t; while(t--)
  26. #define nitin ios_base::sync_with_stdio(false); cin.tie(nullptr)
  27. #define PI 3.141592653589793238
  28. #define mem0(x) memset(x,0,sizeof x)
  29. #define mem1(x) memset(x,-1,sizeof x)
  30. #define pr pair<int,int>
  31. #define vi vector<int>
  32. #define vvi vector<vi>
  33. #define vpr vector<pr>
  34. using namespace std;
  35. template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.f << ", " << p.second << ')'; }
  36. template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
  37.  
  38. void dbg_out() { cerr << endl; }
  39. template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
  40.  
  41. #ifdef NITIN
  42. #define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
  43. #else
  44. #define dbg(...)
  45. #endif
  46.  
  47. int power(int x, int y, int p) {
  48. int res = 1;
  49. x = x % p;
  50. while (y > 0) {
  51. if (y & 1)
  52. res = (res * x) % p;
  53. y = y >> 1;
  54. x = (x * x) % p;
  55. }
  56. return res;
  57. }
  58. int modi(int a, int m) {
  59. return power(a, m - 2, m);
  60. }
  61. void solve() {
  62. int b,w;
  63. cin>>b>>w;
  64. int top=b*(b-1);
  65. top%=mod;
  66. int bottom=((b+w-1)*(b+w-1)-w*w);
  67. bottom%=mod;
  68. top+=bottom;
  69. top%=mod;
  70. top*=w;
  71. top%=mod;
  72. bottom*=(b+2*w);
  73. bottom%=mod;
  74. top%=mod;
  75. bottom%=mod;
  76. top*=modi(bottom,mod);
  77. cout<<top%mod<<endl;
  78.  
  79. }
  80.  
  81. int32_t main() {
  82. nitin;
  83.  
  84. solve();
  85. }
Success #stdin #stdout 0s 5432KB
stdin
Standard input is empty
stdout
-9750542