CF2204C.Spring
入门
通过率:0%
时间限制:2.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Alice, Bob, and Carol visit a spring to collect water. Alice visits every a days (on days a,2a,3a,…), Bob visits every b days (on days b,2b,3b,…), and Carol visits every c days (on days c,2c,3c,…).
When only one person visits, they collect 6 liters of water. If multiple people visit, the water is divided equally: two people take 3 liters each, and three people take 2 liters each.
Your task is to calculate how much water Alice, Bob, and Carol collect over m days, starting from day 1.
爱丽丝、鲍勃和卡罗尔前往一处泉水取水。爱丽丝每 a 天去一次(即在第 a,2a,3a,… 天去),鲍勃每 b 天去一次(即在第 b,2b,3b,… 天去),卡罗尔每 c 天去一次(即在第 c,2c,3c,… 天去)。
当仅有一人前往时,此人取走 6 升水;若有多人同日前往,则水量均分:两人同去时各取 3 升,三人同去时各取 2 升。
你的任务是计算从第 1 天起,持续 m 天内,爱丽丝、鲍勃和卡罗尔各自总共取走多少升水。
输入格式
The first line contains a single integer t (1≤t≤104) — the number of test cases.
The only line of each test case contains four integers a, b, c, and m (1≤a,b,c≤106; 1≤m≤1017).
第一行包含一个整数 t(1≤t≤104)—— 测试用例的数量。
每个测试用例仅一行,包含四个整数 a、b、c 和 m(1≤a,b,c≤106;1≤m≤1017)。
输出格式
For each test case, print three integers — the number of liters of water that Alice, Bob, and Carol collect over m days.
对于每个测试用例,输出三个整数——Alice、Bob 和 Carol 在 m 天内收集的水的升数。
输入输出样例
输入#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 1, only Bob visits the spring, and he collects 6 liters;
- on day 2, Alice and Bob visit the spring, and they each collect 3 liters;
- on day 3, Bob and Carol visit the spring, and they each collect 3 liters;
- on day 4, Alice and Bob visit the spring, and they each collect 3 liters;
- on day 5, only Bob visits the spring, and he collects 6 liters;
- on day 6, Alice, Bob, and Carol visit the spring, and they each collect 2 liters;
- on day 7, only Bob visits the spring, and he collects 6 liters;
- on day 8, Alice and Bob visit the spring, and they each collect 3 liters;
- on day 9, Bob and Carol visit the spring, and they each collect 3 liters;
- on day 10, Alice and Bob visit the spring, and they each collect 3 liters.
考虑第一个例子:
- 第 1 天,只有 Bob 访问泉水,他收集了 6 升;
- 第 2 天,Alice 和 Bob 访问泉水,他们每人收集了 3 升;
- 第 3 天,Bob 和 Carol 访问泉水,他们每人收集了 3 升;
- 第 4 天,Alice 和 Bob 访问泉水,他们每人收集了 3 升;
- 第 5 天,只有 Bob 访问泉水,他收集了 6 升;
- 第 6 天,Alice、Bob 和 Carol 访问泉水,他们每人收集了 2 升;
- 第 7 天,只有 Bob 访问泉水,他收集了 6 升;
- 第 8 天,Alice 和 Bob 访问泉水,他们每人收集了 3 升;
- 第 9 天,Bob 和 Carol 访问泉水,他们每人收集了 3 升;
- 第 10 天,Alice 和 Bob 访问泉水,他们每人收集了 3 升。
输入解题思路,AI测评打分。不知道怎么写?