![](https://i-blog.csdnimg.cn/blog_migrate/2ac2514748cdcee12bcd62b9ba8d60e5.png)
![](https://i-blog.csdnimg.cn/blog_migrate/bcade4c2251f0a4f9df6a5ffefef7a7a.png)
By we denote the quotient of integer division of x and y. By
we denote the remainder of integer division of x and y. You can read more about these operations here: http://goo.gl/AcsXhT.
The answer may be large, so please print its remainder modulo 1 000 000 007 (109 + 7). Can you compute it faster than Dreamoon?
The single line of the input contains two integers a, b (1 ≤ a, b ≤ 107).
Print a single integer representing the answer modulo 1 000 000 007 (109 + 7).
1 1
0
2 2
8
For the first sample, there are no nice integers because is always zero.
For the second sample, the set of nice integers is {3, 5}.
解题思路:这题就是一个简单的推导公式的题目,将x%b=1-->b-1和a=1-->a所有情况算出的x值加起来,注意横线代表的是div(x,b)%mod(x,b)必须等于0,不要和计算机中的除法弄混了,这题公式一会儿推导出来了,就是把该除法当成计算机中的除法,然后导致各种WA,最后此发现自己脑残了,mark以下,下次遇到这种情况得注意。
/* ***********************************************
Author :sponge_wxy
Created Time :2015年09月06日 星期日 09时49分38秒
File Name :476C.cpp
************************************************ */
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
const double pi = acos(-1.0);
const int mod = 1000000000 + 7;
ll cal_one(ll x) {
return (x + 1) * x / 2;
}
ll cal_two(ll x) {
return x * (x + 1) * (2 * x + 1) / 6;
}
int main() {
ll a, b;
cin >> a >> b;
//ll x = b * cal_two(b-1);
//ll y = b * (cal_two(b-1)-cal_one(b-1))/2 + cal_two(b-1);
//cout << cal_one(a) * x + a * y << endl;
//cout << cal_one(a) * (cal_two(b-1) + a * (cal_two(b-1)-cal_one(b-1))/2) << endl;
/*
* int ans = 0;
for(int k = 1; k <= a; ++k) {
for(int y = 1; y < b; ++y) {
ans += k * b * y * y + cal_one(y-1) * b + y * y;
}
}
printf("%d\n", ans);
*/
ll ans = 1;
ans = ans * b * (b - 1) / 2;
ans %= mod;
ll t = (1+a)*a/2;
t %= mod;
t = b * t % mod;
t += a;
ans = ans * t % mod;
cout << ans << endl;
//ans = ans * (a + b*((1+a)*a/2)%mod) % mod;
//cout << ans << endl;
return 0;
}