CF2204C.Spring

入门

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Alice, Bob, and Carol visit a spring to collect water. Alice visits every aa days (on days a,2a,3a,…a, 2a, 3a, \dots), Bob visits every bb days (on days b,2b,3b,…b, 2b, 3b, \dots), and Carol visits every cc days (on days c,2c,3c,…c, 2c, 3c, \dots).

When only one person visits, they collect 66 liters of water. If multiple people visit, the water is divided equally: two people take 33 liters each, and three people take 22 liters each.

Your task is to calculate how much water Alice, Bob, and Carol collect over mm days, starting from day 11.

爱丽丝、鲍勃和卡罗尔前往一处泉水取水。爱丽丝每 aa 天去一次(即在第 a,2a,3a,…a, 2a, 3a, \dots 天去),鲍勃每 bb 天去一次(即在第 b,2b,3b,…b, 2b, 3b, \dots 天去),卡罗尔每 cc 天去一次(即在第 c,2c,3c,…c, 2c, 3c, \dots 天去)。

当仅有一人前往时,此人取走 66 升水;若有多人同日前往,则水量均分:两人同去时各取 33 升,三人同去时各取 22 升。

你的任务是计算从第 11 天起,持续 mm 天内,爱丽丝、鲍勃和卡罗尔各自总共取走多少升水。

输入格式

The first line contains a single integer tt (1≤t≤1041 \le t \le 10^4) — the number of test cases.

The only line of each test case contains four integers aa, bb, cc, and mm (1≤a,b,c≤1061 \le a, b, c \le 10^6; 1≤m≤10171 \le m \le 10^{17}).

第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4)—— 测试用例的数量。

每个测试用例仅一行,包含四个整数 aa、bb、cc 和 mm(1≤a,b,c≤1061 \le a, b, c \le 10^6;1≤m≤10171 \le m \le 10^{17})。

输出格式

For each test case, print three integers — the number of liters of water that Alice, Bob, and Carol collect over mm days.

对于每个测试用例,输出三个整数——Alice、Bob 和 Carol 在 mm 天内收集的水的升数。

输入输出样例

  • 输入#1

    4
    2 1 3 10
    1 1 8 5
    6 20 15 1000
    650650 1092 157437 100000000000000000

    输出#1

    14 38 8 
    15 15 0 
    881 236 281 
    845294870595 549337065358857 3774389867286

说明/提示

Consider the first example:

  • on day 11, only Bob visits the spring, and he collects 66 liters;
  • on day 22, Alice and Bob visit the spring, and they each collect 33 liters;
  • on day 33, Bob and Carol visit the spring, and they each collect 33 liters;
  • on day 44, Alice and Bob visit the spring, and they each collect 33 liters;
  • on day 55, only Bob visits the spring, and he collects 66 liters;
  • on day 66, Alice, Bob, and Carol visit the spring, and they each collect 22 liters;
  • on day 77, only Bob visits the spring, and he collects 66 liters;
  • on day 88, Alice and Bob visit the spring, and they each collect 33 liters;
  • on day 99, Bob and Carol visit the spring, and they each collect 33 liters;
  • on day 1010, Alice and Bob visit the spring, and they each collect 33 liters.

考虑第一个例子:

  • 第 11 天,只有 Bob 访问泉水,他收集了 66 升;
  • 第 22 天,Alice 和 Bob 访问泉水,他们每人收集了 33 升;
  • 第 33 天,Bob 和 Carol 访问泉水,他们每人收集了 33 升;
  • 第 44 天,Alice 和 Bob 访问泉水,他们每人收集了 33 升;
  • 第 55 天,只有 Bob 访问泉水,他收集了 66 升;
  • 第 66 天,Alice、Bob 和 Carol 访问泉水,他们每人收集了 22 升;
  • 第 77 天,只有 Bob 访问泉水,他收集了 66 升;
  • 第 88 天,Alice 和 Bob 访问泉水,他们每人收集了 33 升;
  • 第 99 天,Bob 和 Carol 访问泉水,他们每人收集了 33 升;
  • 第 1010 天,Alice 和 Bob 访问泉水,他们每人收集了 33 升。

输入解题思路,AI测评打分。不知道怎么写?

首页