Skip to content

Instantly share code, notes, and snippets.

@monhime

monhime/ABC162C.gyp

Created Apr 13, 2020
Embed
What would you like to do?
ABC162 C問題 解答
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
You can’t perform that action at this time.