fork download
  1.  
  2. //BISMILLAHIRRAHMANIRRAHIM
  3. /*
  4.  manus tar shopner soman boro
  5.  Author :: Shakil Ahmed
  6. .............AUST_CSE27.........
  7.  prob ::
  8.  Type ::
  9.  verdict::
  10.  */
  11.  
  12. #include <bits/stdc++.h>
  13. #define pb push_back
  14. #define mp make_pair
  15. #define pi acos(-1.0)
  16. #define ff first
  17. #define ss second
  18. #define re return
  19. #define QI queue<int>
  20. #define SI stack<int>
  21. #define SZ(x) ((int) (x).size())
  22. #define all(x) (x).begin(), (x).end()
  23. #define sqr(x) ((x) * (x))
  24. #define memo(a,b) memset((a),(b),sizeof(a))
  25. #define G() getchar()
  26. #define MAX3(a,b,c) max(a,max(b,c))
  27.  
  28. double const EPS=3e-8;
  29. using namespace std;
  30.  
  31. #define FI freopen ("input.txt", "r", stdin)
  32. #define FO freopen ("output.txt", "w", stdout)
  33.  
  34. typedef long long Long;
  35. typedef long long int64;
  36. typedef unsigned long long ull;
  37. typedef vector<int> vi ;
  38. typedef set<int> si;
  39. typedef vector<Long>vl;
  40. typedef pair<int,int>pii;
  41. typedef pair<string,int>psi;
  42. typedef pair<Long,Long>pll;
  43. typedef pair<double,double>pdd;
  44. typedef vector<pii> vpii;
  45.  
  46. // For loop
  47.  
  48. #define forab(i, a, b) for (__typeof (b) i = (a) ; i <= b ; ++i)
  49. #define rep(i, n) forab (i, 0, (n) - 1)
  50. #define For(i, n) forab (i, 1, n)
  51. #define rofba(i, a, b) for (__typeof (b)i = (b) ; i >= a ; --i)
  52. #define per(i, n) rofba (i, 0, (n) - 1)
  53. #define rof(i, n) rofba (i, 1, n)
  54. #define forstl(i, s) for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
  55.  
  56. template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
  57. template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
  58.  
  59. //Fast Reader
  60. template<class T>inline bool read(T &x){int c=getchar();int sgn=1;while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; x*=sgn; return ~c;}
  61.  
  62. //int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
  63. //int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
  64. //int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
  65. //int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction
  66.  
  67. /* ************************************** My code start here ****************************************** */
  68. const Long mod = 1000000007 ;
  69. Long a , b ;
  70. long long BigMod(long long a,long long b,long long m)
  71. {
  72. if(b==0) return 1;
  73. long long x=BigMod(a,b/2,m);
  74. x=(x*x)%m;
  75. if(b%2)
  76. x=(x*a)%m;
  77. return x;
  78. }
  79. long long ModInverse(long long a,long long m)
  80. {
  81. return BigMod(a,m-2,m);
  82. }
  83.  
  84. Long cal(Long first , Long n )
  85. {
  86. Long x , y , res ;
  87. x = (( first + first ) % mod + ((( n - 1 )%mod) * b ) % mod ) % mod ;
  88.  
  89.  
  90. res = (( n % mod ) * x )%mod ;
  91.  
  92. res = ((res * ModInverse(2,mod) )%mod + mod)%mod;
  93. return res ;
  94. }
  95. int main()
  96. {
  97. //ios_base::sync_with_stdio(0); cin.tie(0);
  98. cin >> a >> b ;
  99.  
  100.  
  101. Long ans = 0 ;
  102. Long first = b + 1 ;
  103. for ( int i = 1 ; i < b ; i++ )
  104. {
  105. Long n = ( a * i ) ;
  106. ans = ( ans + cal(first,n) + mod + mod ) % mod ;
  107. first += ( b + 1 ) ;
  108. first = (first + mod ) % mod ;
  109. }
  110.  
  111. cout << ( ans + mod + mod ) % mod << endl ;
  112. return 0;
  113. }
Success #stdin #stdout 0s 3344KB
stdin
Standard input is empty
stdout
0