Calendar Reform CF172D

Reforms have started in Berland again! At this time, the Parliament is discussing the reform of the calendar. To make the lives of citizens of Berland more varied, it was decided to change the calendar. As more and more people are complaining that "the years fly by...", it was decided that starting from the next year the number of days per year will begin to grow. So the coming year will have exactly a days, the next after coming year will have a + 1 days, the next one will have a + 2 days and so on. This schedule is planned for the coming n years (in the n-th year the length of the year will be equal a + n - 1 day).

No one has yet decided what will become of months. An MP Palevny made the following proposal.

  • The calendar for each month is comfortable to be printed on a square sheet of paper. We are proposed to make the number of days in each month be the square of some integer. The number of days per month should be the same for each month of any year, but may be different for different years.
  • The number of days in each year must be divisible by the number of days per month in this year. This rule ensures that the number of months in each year is an integer.
  • The number of days per month for each year must be chosen so as to save the maximum amount of paper to print the calendars. In other words, the number of days per month should be as much as possible.

These rules provide an unambiguous method for choosing the number of days in each month for any given year length. For example, according to Palevny's proposition, a year that consists of 108 days will have three months, 36 days each. The year that consists of 99 days will have 11 months, 9 days each, and a year of 365 days will have 365 months, one day each.

The proposal provoked heated discussion in the community, the famous mathematician Perelmanov quickly calculated that if the proposal is supported, then in a period of n years, beginning with the year that has a days, the country will spend p sheets of paper to print a set of calendars for these years. Perelmanov's calculations take into account the fact that the set will contain one calendar for each year and each month will be printed on a separate sheet.

Repeat Perelmanov's achievement and print the required number p. You are given positive integers a and n. Perelmanov warns you that your program should not work longer than four seconds at the maximum test.

Input

The only input line contains a pair of integers an (1 ≤ a, n ≤ 107; a + n - 1 ≤ 107).

Output

Print the required number p.

Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use cin, cout streams or the %I64d specifier.

Examples

Input

25 3

Output

30

Input

50 5

Output

125

Note

A note to the first sample test. A year of 25 days will consist of one month containing 25 days. A year of 26 days will consist of 26 months, one day each. A year of 27 days will have three months, 9 days each.

把一个数分为 平方数 * 非平方数 最后把非平方数的和加起来

#include <bits/stdc++.h>
using namespace std;
int f[10000010];
int main()
{
	int n,m;
	cin >> n >> m;
	for(int i = n;i < n+m; i++)
		f[i] = i;
	for(int i = 2;i*i < n+m; i++){
		int temp = i*i,sum = (n+temp-1)/temp*temp; //sum为大于n的最小的temp的倍数 也就是一个平方的倍数 
		for(int j = sum;j < n+m; j+=temp){ //对在n 到 n+m-1 中的每一个平方的倍数都除以该平方 直到不能整除为止 剩下的就是月份数 
			while(f[j] % temp == 0){
				f[j] /= temp;
			}
		}
	}
	long long ans = 0;
	for(int i = n;i < n+m; i++)
		ans += f[i];
	cout << ans;
	return 0;
} 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值