核桃的数量
来源:互联网 发布:php网站后台模板下载 编辑:程序博客网 时间:2024/04/25 22:49
问题描述
小张是软件项目经理,他带领3个开发组。工期紧,今天都在加班呢。为鼓舞士气,小张打算给每个组发一袋核桃(据传言能补脑)。他的要求是:
1. 各组的核桃数量必须相同
2. 各组内必须能平分核桃(当然是不能打碎的)
3. 尽量提供满足1,2条件的最小数量(节约闹革命嘛)
输入格式
输入包含三个正整数a, b, c,表示每个组正在加班的人数,用空格分开(a,b,c<30)
输出格式
输出一个正整数,表示每袋核桃的数量。
样例输入1
2 4 5
样例输出1
20
样例输入2
3 1 1
样例输出2
3
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n[]=new int[3];
for(int i=0;i<3;i++)//输入3个数
{
n[i]=sc.nextInt();
}
int temp1,temp2,temp3,temp4;
temp1=gcd(n[0],n[1]);
temp2=n[0]*n[1]/temp1;
temp3=gcd(temp2,n[2]);
temp4=temp2*n[2]/temp3;
System.out.println(temp4);
}
public static int gcd(int a,int b){
if(a<b){
int temp=a;
a=b;
b=temp;
}
int c;
c=a%b;
while(c!=0)
{
a=b;
b=c;
c=a%b;
}
return b;
}
}
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n[]=new int[3];
for(int i=0;i<3;i++)//输入3个数
{
n[i]=sc.nextInt();
}
int temp1,temp2,temp3,temp4;
temp1=gcd(n[0],n[1]);
temp2=n[0]*n[1]/temp1;
temp3=gcd(temp2,n[2]);
temp4=temp2*n[2]/temp3;
System.out.println(temp4);
}
public static int gcd(int a,int b){
if(a<b){
int temp=a;
a=b;
b=temp;
}
int c;
c=a%b;
while(c!=0)
{
a=b;
b=c;
c=a%b;
}
return b;
}
}
0 0
- 核桃的数量
- 蓝桥杯 核桃的数量
- 蓝桥杯:核桃的数量
- 核桃的数量
- 核桃的数量
- 蓝桥杯:核桃的数量
- 33.核桃的数量
- 核桃的数量
- 核桃的数量
- 蓝桥杯 - 核桃的数量
- 核桃的数量
- NYOJ核桃的数量
- 蓝桥杯 核桃的数量
- 蓝桥杯:核桃的数量
- 核桃的数量
- 核桃的数量
- 核桃的数量
- 核桃的数量
- poj2559 Largest Rectangle in a Histogram(单调栈)
- GDB调试流程
- 二叉树平衡检查
- mysql基本语法四
- hdu 5698瞬间移动(组合数取模、卢卡斯定理)
- 核桃的数量
- 自定义URL协议在Web中启动本地应用程序
- Android 使用小技巧之 :new Handler().postDelayed() 延迟intent跳转
- mini2440一线触摸屏的tslib移植说明
- 2016-5-23计划
- C 语言打桩问题(interpositioning)
- AYIT2016省赛集训第六周周一赛 H -高桥和低桥
- FPGA视觉从入门到放弃——削苹果剩下的小波矩
- java-代理模式的复习