//UVA1363Joseph'sProblem
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
int main() {
int n, k;
while(scanf("%d%d", &n, &k) == 2) {
LL ans = 0;
for(int i = 1; i <= n; i++) {
int p = k / i;//1
int q = k % i;//1
int cnt = n - i;//1
if(p > 0) cnt = min(cnt, q / p);//计算除了首项之外还剩下的项数
LL sum = (LL)(2 * q - cnt * p) * (cnt + 1) / 2;//小学必备高斯公式
ans += sum;
i += cnt;
}
printf("%lld\n", ans);
}
return 0;
}
/*
5 3
*/
UVA1363Joseph'sProblem
最新推荐文章于 2019-07-09 20:23:44 发布