回答編集履歴
1
追記
test
CHANGED
@@ -1,7 +1,35 @@
|
|
1
|
+
シグネチャは次のようになっています。
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
> ```C++
|
6
|
+
|
7
|
+
template <class InputIterator, class T>
|
8
|
+
|
9
|
+
T accumulate(InputIterator first, InputIterator last, T init);
|
10
|
+
|
11
|
+
> ```
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
引用元: [cpprefjp - C++日本語リファレンス / numeric / accumulate](https://cpprefjp.github.io/reference/numeric/accumulate.html)
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
1
|
-
|
21
|
+
返り値は引数 init の型と同一になりますから、そこにlong long 型のリテラルを渡せば良いです。
|
2
22
|
|
3
23
|
```C++
|
4
24
|
|
5
25
|
std::accumulate(test.begin(), test.end(), 0LL)
|
6
26
|
|
7
27
|
```
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
> 最大桁数の(long long)でキャストしてみても結果変わらず。
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
演算途中でオーバーフローが起きているのなら、返り値をいじっても意味が無いです。
|