核桃的数量

    技术2022-07-11  93

    小张是软件项目经理,他带领3个开发组。工期紧,今天都在加班呢。为鼓舞士气,小张打算给每个组发一袋核桃(据传言能补脑)。他的要求是:

    各组的核桃数量必须相同

    各组内必须能平分核桃(当然是不能打碎的)

    尽量提供满足1,2条件的最小数量(节约闹革命嘛) `public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); int sum = a * b * c; for (int i = 1; i < sum; i++) { if (i % a == 0 && i % b == 0 && i % c == 0) { sum = i; break; } } System.out.println(sum); }

    Processed: 0.011, SQL: 9