历届试题 PREV-1 核桃的数量
来源:互联网 发布:淘宝怎么添加收藏链接 编辑:程序博客网 时间:2024/04/28 22:19
问题描述
小张是软件项目经理,他带领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.Scanner;public class Main{public static void main(String[] args) {Scanner input = new Scanner(System.in);int a = input.nextInt();int b = input.nextInt();int c = input.nextInt();int result = method(method(a,b),c);System.out.println(result);}public static int method(int a,int b){int r = a,s = a,t = b;if (a<b){r = a;a = b;b = r;}while(r!=0){r = a % b;a = b;b = r;}return s*t/a;}}
阅读全文
0 0
- 历届试题 PREV-1 核桃的数量
- 蓝桥杯 PREV-1 历届试题 核桃的数量
- PREV-1 核桃的数量
- PREV-1核桃的数量
- PREV-1 核桃的数量
- 历届试题 核桃的数量
- 历届试题 核桃的数量
- 历届试题 核桃的数量
- 历届试题 核桃的数量
- 【历届试题】核桃的数量
- 历届试题 核桃的数量
- 历届试题 核桃的数量
- 历届试题 核桃的数量
- 历届试题 核桃的数量
- 历届试题 核桃的数量
- 历届试题 核桃的数量
- 历届试题 核桃的数量
- 历届试题 核桃的数量
- 862A Mahmoud and Ehab and the MEX (水)
- android基础知识回顾--ContentProvider简单用法
- Balls and Boxes CodeForces
- 我用过的sqlite和mysql
- python运维__fifth_chapter(5)--xml.etree.Elementtree 读取XML文档
- 历届试题 PREV-1 核桃的数量
- Linux云服务器下Tomcat部署超详细
- Tensorflow Python 2.7搭建
- IPSEC原理及组成
- eclipse关于struts2整合hibernate遇到的导入包的问题
- log4net的运用示例
- poj3648 Wedding 2-sat
- 历届试题 PREV-2 打印十字图
- js数组去重