黑心啤酒厂为了让大家买啤酒,会把一瓶酒设计成恰好能倒七杯。由于聚会时经常会有大家一起干杯这样的事情,干杯之前又要给每个人都倒满,所以来两个人的时候,干完三轮,恰好多一杯;三个人的时候,干完两轮,恰好多一杯;四个人的时候会多三杯。在上述情况下,为了践行不浪费的原则,就会多买一瓶啤酒,再干一轮。当然多买的啤酒可能又有多了……然后循环往复,喝了好多好多。直到啤酒刚刚好喝完为止。
现在啤酒厂把酒瓶设计成刚好能倒 x 杯,请依次求出有 2 人、3 人,一直到 n 人参加聚会时,啤酒厂各能卖出多少瓶啤酒。
Input
输入只有一行,两个整数 x,n (1≤x≤10^9,2≤n≤10^5)。
Output
输出 n−1 行,分别表示 2,3,…,n 人参加聚会时,能卖出的啤酒瓶数。
Examples
Input
7 5
Output
2
3
4
5
思路:最小公倍数,注意开longlong
代码如下
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<cmath>
#include<string>
#include<map>
#define LL long long
#define ULL unsigned long long
using namespace std;
LL gcd(LL a,LL b)
{
if(b==0)return a;
else return gcd(b,a%b);
}
LL lcm(LL a,LL b)
{
return a/gcd(a,b)*b;
}
int main()
{
int n,x;
scanf("%d%d",&x,&n);
for(int i=2;i<=n;i++)
{
LL sum=lcm(x,i);
printf("%d\n",sum/x);
}
return 0;
}