cpython3


私信TA

用户名:smartZhou

访问量:71580

签 名:

等  级
排  名 36
经  验 12926
参赛次数 1
文章发表 99
年  龄 0
在职情况 学生
学  校
专  业 计算机科学与技术

  自我简介:

解题思路:
本题要求:

  1.   各组的核桃数量必须相同 
    2.  各组内必须能平分核桃(当然是不能打碎的) 
    3.  尽量提供满足1,2条件的最小数量(节约闹革命嘛) 注意事项:

  2. 综上所述知本题的实质是求三个数的最小公倍数。、

求三个数a,b,c的最小公倍数n,n满足

n%a==0

n%b==0

n%c==0

并且n要求最小!

#include <stdio.h>
int main()
{
	int a,b,c,n=1;
	scanf("%d%d%d",&a,&b,&c);
	while(1)
	{
		if((n%a==0)&&(n%b==0)&&(n%c==0))
		{
			break;
		}
		n++;
	}
	printf("%d",n);
	return 0;
}


 

0.0分

1 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答

代码解释器

  评论区

int max(int a, int b)
{
    return a > b ? a : b;
}
int main()
{
    int a,b, c;
    scanf("%d %d %d", &a, &b, &c);
    int d = max(a, max(b, c));
    while (d%a!=0||d%b!=0||d%c!=0)
    {
        d++;
    }
    printf("%d", d);
    return 0;
}
2024-03-25 19:20:02
  • «
  • 1
  • »