3262. 黑心啤酒厂

Fifnmar

题意很简单,就是求出一瓶酒的杯数与人数的最小公倍数(lcm)。wa的同学注意数据范围比较大,要用 unsigned long long

#include <iostream>
#include <numeric>

int main() {
    unsigned long long n, x;
    std::cin >> x >> n;
    for (unsigned long long i = 2; i <= n; ++i)
        printf("%u\n", std::lcm(x, i) / x);
}
灬狗蛋灬
[已删除]
32Leoric

我也这样。。。懵了

灬狗蛋灬

我知道了,应该m的值循环过后没有返回1

LzQuarter

GCD需用标程

cww970329

py死命T,辣鸡

YZAZJL

include

include

include

include

using namespace std;

long long gcd(long long a, long long b){
if(b == 0) return a;
return gcd(b, a%b);
}

int main()
{
long long nb, n;// n杯,n个人
while(cin >> nb >> n){
int i;
if(nb >= 1 && n >= 2){
for(i = 2; i <= n; i++){
long long lcm = (nb * i) / gcd(nb, i);
cout << lcm / nb << endl;
}
}
}
return 0;
}

你当前正在回复 博客/题目
存在问题!