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


    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 (1x109,2n105)

    Output

    输出 n1 行,分别表示 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
    ",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;
    }
  • 相关阅读:
    时间操作
    2021.10.9数据结构实验课作业
    2021.9.28数据结构实验课作业
    2021.9.15数据结构实验课作业
    2021.9.7数据结构实验课作业
    苹果ios开发,CocoaPods安装方法-2021/9/11
    写组件库文档常用的技术
    document.execCommand 的用法
    手写JSON.stringify
    Object常用方法
  • 原文地址:https://www.cnblogs.com/kimsimple/p/6859048.html
Copyright © 2020-2023  润新知