您的位置:首页 > 其它

EOJ-大学生程序设计邀请赛(华东师范大学)-E-黑心啤酒厂

2017-05-15 23:46 253 查看

E. 黑心啤酒厂

Time limit per test: 1.0 seconds

Time limit all tests: 1.0 seconds

Memory limit: 256 megabytes

Accept / Submit: 1184 / 4093

黑心啤酒厂为了让大家买啤酒,会把一瓶酒设计成恰好能倒七杯。由于聚会时经常会有大家一起干杯这样的事情,干杯之前又要给每个人都倒满,所以来两个人的时候,干完三轮,恰好多一杯;三个人的时候,干完两轮,恰好多一杯;四个人的时候会多三杯。在上述情况下,为了践行不浪费的原则,就会多买一瓶啤酒,再干一轮。当然多买的啤酒可能又有多了……然后循环往复,喝了好多好多。直到啤酒刚刚好喝完为止。

现在啤酒厂把酒瓶设计成刚好能倒 x 杯,请依次求出有 2 人、3 人,一直到 n 人参加聚会时,啤酒厂各能卖出多少瓶啤酒。

Input

输入只有一行,两个整数 x,n (1≤x≤109,2≤n≤105)。

Output

输出 n−1 行,分别表示 2,3,…,n 人参加聚会时,能卖出的啤酒瓶数。

Examples

input
7 5
output
2
3
4
5

#include "iostream"
#include "cstdio"
#include "cstring"
#include "string"
#include "cmath"
#include "map"
#include "vector"
#include "stack"
#include "algorithm"
#define LL long long
#define PI acos(-1.0)
#define E exp(1.0)
#define MOD 1000000007
#define N 50010
using namespace std;
LL GCD(LL a,LL b)
{
return b==0?a:GCD(b,a%b);
}
int main()
{
LL x,n;
while(scanf("%lld%lld",&x,&n)!=EOF)
{
for(int i=2;i<=n;i++)
{
LL temp=x*i/GCD(x,i);
printf("%lld\n",temp/x);
}
}
return 0;
}

 

long long gcd(long long x, long long y)
{
if (!x || !y)
{
return x > y ? x : y;
}
for (long long t; t = x % y; x = y, y = t);
return y;
}

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐