結果
| 問題 |
No.443 GCD of Permutation
|
| コンテスト | |
| ユーザー |
💕💖💞
|
| 提出日時 | 2016-11-19 23:32:15 |
| 言語 | Go (1.23.4) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 1,000 ms |
| コード長 | 899 bytes |
| コンパイル時間 | 14,326 ms |
| コンパイル使用メモリ | 233,368 KB |
| 実行使用メモリ | 9,848 KB |
| 最終ジャッジ日時 | 2024-10-14 00:04:15 |
| 合計ジャッジ時間 | 15,202 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 28 |
ソースコード
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)
}
💕💖💞