-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
76 lines (64 loc) · 1.7 KB
/
Copy pathmain.cpp
File metadata and controls
76 lines (64 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// SPDX-License-Identifier: AGPL-3.0-or-later
// SPDX-FileCopyrightText: 2020-2025 nanoseeds
//@Tag Done
#include <tuple>
#include <vector>
#include <cstdint>
#include <iostream>
#include <algorithm>
#ifdef ALGORITHM_TEST_MACRO
namespace lab_02_B{
#endif
using std::cin;
using std::tie;
using std::cout;
using std::vector;
static constexpr const char end{'\n'};
using num_t = int64_t;
using input_type = vector<num_t>;
using output_type = vector<num_t>;
inline input_type read();
output_type cal(const input_type &data);
void output(const output_type &data);
int main() {
auto input_data = read();
auto output_data = cal(input_data);
output(output_data);
return 0;
}
inline input_type read() {
num_t T{0};
std::cin >> T;
input_type inputs(T, 0);
for (int32_t i{0}; i < T; ++i) {
std::cin >> inputs[i];
}
return inputs;
}
output_type cal(const input_type &data) {
output_type outputs(data.size(), static_cast<output_type::value_type>(0));
const auto input_size = static_cast<int32_t>(data.size());
for (int32_t i{0}; i < input_size; ++i) {
outputs[i] = (data[i] * (data[i] + 1) * (data[i] + 2)) / 6;
}
return outputs;
}
void output(const output_type &data) {
for (auto &&num: data) {
std::cout << num << end;
}
}
static const auto faster_streams = [] {
srand(time(nullptr));
// use time to init the random seed
std::ios::sync_with_stdio(false);
std::istream::sync_with_stdio(false);
std::ostream::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
// 关闭c++风格输入输出 , 与C风格输入输出的同步,提高性能.
return 0;
}();
#ifdef ALGORITHM_TEST_MACRO
}
#endif