Created
April 13, 2020 03:10
-
-
Save monhime/9bf9b9b66d3f0e5b8f331829684f2061 to your computer and use it in GitHub Desktop.
ABC162 C問題 解答
This file contains 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
import sys | |
import math | |
from functools import reduce | |
def input(): return sys.stdin.readline().rstrip() | |
def gcd(*numbers): | |
return reduce(math.gcd, numbers) | |
def main(): | |
k=int(input()) | |
sum=0 | |
for i in range(1,k-1): | |
for j in range(i+1,k): | |
for l in range(j+1,k+1): | |
sum+=gcd(i,j,l)*6 | |
for i in range(1,k+1): | |
for j in range(1,k+1): | |
if i!=j: | |
sum+=gcd(i,j,j)*3 | |
for i in range(1,k+1): | |
sum+=gcd(i,i,i) | |
print(sum) | |
if __name__=='__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment