Created
July 14, 2021 02:10
-
-
Save uchidama/651a8233487dbb8245eb3018fccd3639 to your computer and use it in GitHub Desktop.
AtCoder Beginner Contest 162 [ C - Sum of gcd of Tuples (Easy) ] https://atcoder.jp/contests/abc162/tasks/abc162_c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
[問題] | |
https://atcoder.jp/contests/abc162/tasks/abc162_c | |
''' | |
import sys | |
import functools | |
import math | |
sys.setrecursionlimit(10 ** 6) # 再帰上限の引き上げ | |
input = sys.stdin.readline | |
INF = 2 ** 63 - 1 | |
K = int(input()) | |
ans = 0 | |
for i in range(1, K + 1): | |
for j in range(1,K + 1): | |
for k in range(1,K + 1): | |
A = [i,j,k] | |
# Aの最大公約数を求める | |
gcd = functools.reduce(math.gcd, A) | |
ans += int(gcd) | |
print(ans) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment