結果

問題 No.443 GCD of Permutation
ユーザー 💕💖💞💕💖💞
提出日時 2016-11-19 23:32:15
言語 Go
(1.21.3)
結果
AC  
実行時間 4 ms / 1,000 ms
コード長 899 bytes
コンパイル時間 17,928 ms
コンパイル使用メモリ 208,272 KB
実行使用メモリ 8,408 KB
最終ジャッジ日時 2023-08-04 02:59:34
合計ジャッジ時間 16,812 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,112 KB
testcase_01 AC 3 ms
6,116 KB
testcase_02 AC 2 ms
6,112 KB
testcase_03 AC 3 ms
6,112 KB
testcase_04 AC 2 ms
6,112 KB
testcase_05 AC 2 ms
6,116 KB
testcase_06 AC 3 ms
6,112 KB
testcase_07 AC 2 ms
6,112 KB
testcase_08 AC 2 ms
6,112 KB
testcase_09 AC 2 ms
6,112 KB
testcase_10 AC 2 ms
6,116 KB
testcase_11 AC 2 ms
6,116 KB
testcase_12 AC 2 ms
6,116 KB
testcase_13 AC 3 ms
6,112 KB
testcase_14 AC 4 ms
8,408 KB
testcase_15 AC 3 ms
8,168 KB
testcase_16 AC 3 ms
8,164 KB
testcase_17 AC 3 ms
8,164 KB
testcase_18 AC 4 ms
8,388 KB
testcase_19 AC 3 ms
8,164 KB
testcase_20 AC 4 ms
8,408 KB
testcase_21 AC 4 ms
8,168 KB
testcase_22 AC 3 ms
6,120 KB
testcase_23 AC 2 ms
6,112 KB
testcase_24 AC 3 ms
6,116 KB
testcase_25 AC 3 ms
8,396 KB
testcase_26 AC 4 ms
8,388 KB
testcase_27 AC 3 ms
8,172 KB
testcase_28 AC 4 ms
8,388 KB
testcase_29 AC 3 ms
8,392 KB
testcase_30 AC 3 ms
8,392 KB
testcase_31 AC 4 ms
8,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
)

var rdr = bufio.NewReaderSize(os.Stdin, 10000000)

func gets() string {
	buf := make([]byte, 0, 10000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	text := gets()
	//d := []rune{}
	g := big.NewInt(0)
	g.SetString(text, 10)

	set := make(map[rune]struct{})
	for _, r := range []rune(text) {
		set[r] = struct{}{}
	}
	setl := []rune{}
	for r := range set {
		setl = append(setl, r)
	}
	for _, x := range setl {
		for _, y := range setl {
			if x == y {
				continue
			}
			bx, by, t := big.NewInt(0), big.NewInt(0), big.NewInt(0)
			bx.SetString(string(x), 10)
			by.SetString(string(y), 10)
			t = new(big.Int).Mul(big.NewInt(9), new(big.Int).Abs(new(big.Int).Sub(bx, by)))
			//fmt.Println("a", t, bx, by)
			g.GCD(nil, nil, t, g)
		}
	}
	fmt.Println(g)
}
0