blob: 9a136bdca56dfbce100324bc61231fa65b9fd328 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
#include <cstdint>
#include <iostream>
int main() {
int count;
if (!(std::cin >> count)) return 1;
for (int record = 0; record < count; ++record) {
std::int64_t lower, size, step, base;
if (!(std::cin >> lower >> size >> step >> base) || size < 1) return 1;
// Closed form is independent of pseudocode's indexed loop.
auto sum = size * base + step * size * (size - 1) / 2;
std::cout << sum << ':' << base << ':' << base + (size - 1) * step << '\n';
}
}
|