回答編集履歴
1
追記
answer
CHANGED
@@ -7,4 +7,15 @@
|
|
7
7
|
Python2のころは事情が違っていて、forループは遅い、内包表記やmap関数やitertoolsを使え、と言われていました。
|
8
8
|
Python3の開発で(おそらくは開発者の方がめちゃくちゃがんばって)forループの処理の最適化がなされて、今は愚直にforループを書くのがだいたいにおいて一番速いことが多いです。
|
9
9
|
|
10
|
-
[https://teratail.com/questions/330753#reply-457116](https://teratail.com/questions/330753#reply-457116) あたりも。
|
10
|
+
[https://teratail.com/questions/330753#reply-457116](https://teratail.com/questions/330753#reply-457116) あたりも。
|
11
|
+
|
12
|
+
----
|
13
|
+
|
14
|
+
(追記)
|
15
|
+
|
16
|
+
```python
|
17
|
+
ans = 0
|
18
|
+
for x, y, z in product(range(1, K + 1), repeat = 3):
|
19
|
+
ans += gcd(gcd(x, y), z)
|
20
|
+
```
|
21
|
+
が3重forループとほぼ同様になりませんか。
|