提出 #13434291


ソースコード 拡げる

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	nextReader = newScanner()
	k := nextInt()
	ans := 0
	for a := 1; a <= k; a++ {
		for b := 1; b <= k; b++ {
			for c := 1; c <= k; c++ {
				ans += gcd(a, gcd(b, c))
			}
		}
	}
	fmt.Println(ans)
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}

提出情報

提出日時
問題 C - Sum of gcd of Tuples (Easy)
ユーザ hidapple
言語 Go (1.14.1)
得点 300
コード長 1013 Byte
結果 AC
実行時間 745 ms
メモリ 1780 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 2
AC × 18
セット名 テストケース
Sample sample_01, sample_02
All hand_01, large_01, large_02, large_03, large_04, large_05, random_01, random_02, random_03, random_04, random_05, sample_01, sample_02, small_01, small_02, small_03, small_04, small_05
ケース名 結果 実行時間 メモリ
hand_01 AC 3 ms 1756 KiB
large_01 AC 732 ms 1780 KiB
large_02 AC 721 ms 1776 KiB
large_03 AC 707 ms 1764 KiB
large_04 AC 697 ms 1764 KiB
large_05 AC 686 ms 1764 KiB
random_01 AC 20 ms 1772 KiB
random_02 AC 350 ms 1760 KiB
random_03 AC 154 ms 1760 KiB
random_04 AC 378 ms 1760 KiB
random_05 AC 85 ms 1776 KiB
sample_01 AC 2 ms 1756 KiB
sample_02 AC 745 ms 1764 KiB
small_01 AC 2 ms 1752 KiB
small_02 AC 2 ms 1740 KiB
small_03 AC 1 ms 1740 KiB
small_04 AC 2 ms 1756 KiB
small_05 AC 2 ms 1736 KiB