题目大意:给定a,b,对于一个数x,若x是nice number,则满足(x/b)/(x%b) == [1,a](即结果在1-a之间)问:输出一个数表示 所有nice number的和。思路:令 d = div(x, b), m = mod(x, b), 则:
d = mk
x = db + m
有 x = mkb + m = (kb + 1) * m。求出m,k即可
结果为:
#include <cstdio>
#include <string>
#include <cstring>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <iostream>
#include <sstream>
using namespace std;
#define maxn 1003
#define MOD 1000000007
#define mem(a , b) memset(a , b , sizeof(a))
#define LL __int64
int main()
{
LL a , b , ans , tmp;
while(scanf("%I64d %I64d" , &a , &b) != EOF)
{
tmp = b * (b - 1) / 2;
tmp %= MOD;
ans = a * ( a + 1 ) / 2;
ans %= MOD ;
ans = ans * b % MOD;
ans += a;
ans = ans * tmp % MOD;
printf("%I64d\n" , ans);
}
}