CF172D.Calendar Reform

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

改革再次在伯兰德(Berland)开始了!此次,议会正在讨论日历改革方案。为了使伯兰德公民的生活更加丰富多彩,决定对日历进行调整。由于越来越多的人抱怨“岁月如梭……”,因此决定从下一年起逐年增加每年的天数。于是,即将到来的这一年将恰好有 aa 天,其后一年将有 a+1a+1 天,再后一年将有 a+2a+2 天,依此类推。该计划将持续 nn 年(第 nn 年的长度为 a+n−1a + n - 1 天)。

目前尚无关于“月份”如何设定的最终决定。议员帕列夫尼(Palevny)提出了如下建议:

  • 每个月的日历应舒适地印在一张正方形纸张上。我们提议:每个月的天数必须是某个整数的平方数;同一年内所有月份的天数必须相同,但不同年份之间可以不同;
  • 每年的总天数必须能被该年每月的天数整除。此规则保证了每年的月份数为整数;
  • 每年每月的天数应尽可能大,以最大限度地节省印刷日历所用的纸张(即:每月天数越大,所需纸张越少)。

这些规则为任意给定年长度唯一确定了该年每月的天数。例如,根据帕列夫尼的提案:

  • 一个由 108108 天组成的年份将分为 33 个月,每月 3636 天;
  • 一个由 9999 天组成的年份将分为 1111 个月,每月 99 天;
  • 一个由 365365 天组成的年份将分为 365365 个月,每月 11 天。

该提案在社会上引发了热烈讨论。著名数学家佩雷尔曼诺夫(Perelmanov)迅速计算出:若该提案获得通过,则在从含 aa 天的那一年起的连续 nn 年期间,全国印刷这些年的全套日历共需消耗 pp 张纸。佩雷尔曼诺夫的计算考虑了如下事实:该套日历包含每一年的一份日历,且每个月均单独印在一张纸上。

请复现佩雷尔曼诺夫的成果,并输出所需的总数 pp。你将被给定两个正整数 aa 和 nn。佩雷尔曼诺夫提醒你:你的程序在最大测试用例下的运行时间不得超过四秒。

输入格式

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

唯一的一行输入包含一对整数 aa、nn(1 ≤ a, n ≤ 1071 ≤ a, n ≤ 10^7;a + n − 1 ≤ 107a + n - 1 ≤ 10^7)。

输出格式

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.

输出所需的数字 pp。

请注意,在 C++ 中不要使用 %lld 说明符来读取或写入 64 位整数。推荐使用 cin、cout 流,或 %I64d 说明符。

输入输出样例

  • 输入#1

    25 3

    输出#1

    30
  • 输入#2

    50 5

    输出#2

    125

说明/提示

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.

对第一个样例测试的说明:25天的一年将由一个包含25天的月份组成;26天的一年将由26个每月1天的月份组成;27天的一年将由3个每月9天的月份组成。

输入解题思路,AI测评打分。不知道怎么写?

首页